<!--

    Copyright (C) 2011 Domenico Briganti <dometec@gmail.com>

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>Deploy Manager</title>
 
		<link rel="stylesheet" type="text/css" href="yui/build/reset/reset-min.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/fonts/fonts-min.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/grids/grids-min.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/autocomplete/assets/skins/sam/autocomplete.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/container/assets/skins/sam/container.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/menu/assets/skins/sam/menu.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/button/assets/skins/sam/button.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/calendar/assets/skins/sam/calendar.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/carousel/assets/skins/sam/carousel.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/slider/assets/skins/sam/slider.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/colorpicker/assets/skins/sam/colorpicker.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/paginator/assets/skins/sam/paginator.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/datatable/assets/skins/sam/datatable.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/editor/assets/skins/sam/editor.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/resize/assets/skins/sam/resize.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/imagecropper/assets/skins/sam/imagecropper.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/layout/assets/skins/sam/layout.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/logger/assets/skins/sam/logger.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/profilerviewer/assets/skins/sam/profilerviewer.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/progressbar/assets/skins/sam/progressbar.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/tabview/assets/skins/sam/tabview.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/treeview/assets/skins/sam/treeview.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/yuitest/assets/skins/sam/yuitest.css"> 
		<link rel="stylesheet" type="text/css" href="yui/build/editor/assets/skins/sam/simpleeditor.css"> 
         
        <!-- Page-specific styles -->
        <style type="text/css">
            html {
                background-color: #dfb8df;
            }
            
            em#yahoolabel {
                text-indent: -6em;
                display: block;
                background: url(http://l.yimg.com/a/i/us/nt/b/purpley.1.0.gif) center center no-repeat;
                width: 2em;
                overflow: hidden;
            }

            /*
                Setting the "zoom" property to "1" triggers the "hasLayout" 
                property in IE.  This is necessary to fix a bug IE where 
                mousing mousing off a the text node of MenuItem instance's 
                text label, or help text without the mouse actually exiting the
                boundaries of the MenuItem instance will result in the losing  
                the background color applied when it is selected.
            */
            #filemenu.visible .yuimenuitemlabel,
            #editmenu.visible .yuimenuitemlabel {
                *zoom: 1;
            }

			/*
				Remove "hasLayout" from the submenu of the file menu.			
			*/
            #filemenu.visible .yuimenu .yuimenuitemlabel {
                *zoom: normal;
            }
            
        </style>

		<script type="text/javascript" src="yui/build/yuiloader/yuiloader-debug.js"></script> 
		<script type="text/javascript" src="yui/build/dom/dom-debug.js"></script> 
		<script type="text/javascript" src="yui/build/event/event-debug.js"></script> 
		<script type="text/javascript" src="yui/build/animation/animation-debug.js"></script> 
		<script type="text/javascript" src="yui/build/connection/connection-debug.js"></script> 
		<script type="text/javascript" src="yui/build/datasource/datasource-debug.js"></script> 
		<script type="text/javascript" src="yui/build/autocomplete/autocomplete-debug.js"></script> 
		<script type="text/javascript" src="yui/build/selector/selector-debug.js"></script> 
		<script type="text/javascript" src="yui/build/event-delegate/event-delegate-debug.js"></script> 
		<script type="text/javascript" src="yui/build/event-mouseenter/event-mouseenter-debug.js"></script> 
		<script type="text/javascript" src="yui/build/element/element-debug.js"></script> 
		<script type="text/javascript" src="yui/build/dragdrop/dragdrop-debug.js"></script> 
		<script type="text/javascript" src="yui/build/container/container-debug.js"></script> 
		<script type="text/javascript" src="yui/build/menu/menu-debug.js"></script> 
		<script type="text/javascript" src="yui/build/button/button-debug.js"></script> 
		<script type="text/javascript" src="yui/build/calendar/calendar-debug.js"></script> 
		<script type="text/javascript" src="yui/build/carousel/carousel-debug.js"></script> 
		<script type="text/javascript" src="yui/build/json/json-debug.js"></script> 
		<script type="text/javascript" src="yui/build/swf/swf-debug.js"></script> 
		<script type="text/javascript" src="yui/build/charts/charts-debug.js"></script> 
		<script type="text/javascript" src="yui/build/slider/slider-debug.js"></script> 
		<script type="text/javascript" src="yui/build/colorpicker/colorpicker-debug.js"></script> 
		<script type="text/javascript" src="yui/build/cookie/cookie-debug.js"></script> 
		<script type="text/javascript" src="yui/build/paginator/paginator-debug.js"></script> 
		<script type="text/javascript" src="yui/build/datatable/datatable-debug.js"></script> 
		<script type="text/javascript" src="yui/build/datemath/datemath-debug.js"></script> 
		<script type="text/javascript" src="yui/build/editor/editor-debug.js"></script> 
		<script type="text/javascript" src="yui/build/element-delegate/element-delegate-debug.js"></script> 
		<script type="text/javascript" src="yui/build/event-simulate/event-simulate-debug.js"></script> 
		<script type="text/javascript" src="yui/build/history/history-debug.js"></script> 
		<script type="text/javascript" src="yui/build/resize/resize-debug.js"></script> 
		<script type="text/javascript" src="yui/build/imagecropper/imagecropper-debug.js"></script> 
		<script type="text/javascript" src="yui/build/imageloader/imageloader-debug.js"></script> 
		<script type="text/javascript" src="yui/build/layout/layout-debug.js"></script> 
		<script type="text/javascript" src="yui/build/logger/logger-debug.js"></script> 
		<script type="text/javascript" src="yui/build/profiler/profiler-debug.js"></script> 
		<script type="text/javascript" src="yui/build/profilerviewer/profilerviewer-debug.js"></script> 
		<script type="text/javascript" src="yui/build/progressbar/progressbar-debug.js"></script> 
		<script type="text/javascript" src="yui/build/swfstore/swfstore-debug.js"></script> 
		<script type="text/javascript" src="yui/build/storage/storage-debug.js"></script> 
		<script type="text/javascript" src="yui/build/stylesheet/stylesheet-debug.js"></script> 
		<script type="text/javascript" src="yui/build/tabview/tabview-debug.js"></script> 
		<script type="text/javascript" src="yui/build/treeview/treeview-debug.js"></script> 
		<script type="text/javascript" src="yui/build/uploader/uploader-debug.js"></script> 
		<script type="text/javascript" src="yui/build/yuitest/yuitest-debug.js"></script> 
		<script type="text/javascript" src="base64.js"></script>
		<script type="text/javascript" src="utility.js"></script>
		<script type="text/javascript" src="client.js"></script>
		
        <!-- Page-specific script -->
        <script type="text/javascript">

	        var server = "/deploymanager/"; //"http://localhost:8080/DeployManager/";
	        var username;
	        var password;
	        var role = "none";

	        YAHOO.namespace("DeployManager.container");

	        //Funzioni per la dialog LOGINDIALOG
	        YAHOO.DeployManager.container.loginDialog = {};
	        YAHOO.DeployManager.container.waitDialog = {};
	        YAHOO.DeployManager.container.errorMessageDialog = {};
	        YAHOO.DeployManager.container.EnvironmentDialog = {};
	        YAHOO.DeployManager.container.EnvironmentDialogForm = {};
	        YAHOO.DeployManager.container.alertDialog = {};
	        YAHOO.DeployManager.container.promptDialogForm = {};
	        YAHOO.DeployManager.container.VirtualHostDialog = {};
	        YAHOO.DeployManager.container.VirtualHostDialogForm = {};
	        YAHOO.DeployManager.container.WebAppsDialog = {};
	        YAHOO.DeployManager.container.DeployDialog = {};
	        YAHOO.DeployManager.container.DeployLogDialog = {};
	        YAHOO.DeployManager.container.DeployLogDialog.dialog = new Array();
	        YAHOO.DeployManager.container.WebappStatusDialog = {};
	        YAHOO.DeployManager.container.WebappStatusDialog.dialog = new Array();
	        YAHOO.DeployManager.container.AppsChartDialog = {};
	        YAHOO.DeployManager.container.AppsChartDialog.dialog = new Array();
	        YAHOO.DeployManager.container.StaticContentDialog = {};
	        YAHOO.DeployManager.container.CompareLogDialog = {};
	        YAHOO.DeployManager.container.CompareLogDialog.dialog = new Array();
	        YAHOO.DeployManager.container.TagDialog = {};
	        YAHOO.DeployManager.container.TagLogDialog = {};
	        YAHOO.DeployManager.container.TagLogDialog.dialog = new Array();
	        YAHOO.DeployManager.container.StaticNotifyDialog = {};
	        YAHOO.DeployManager.container.HelpDialog = {};
	        
	        
            /* Initialize and render the MenuBar when the page's DOM is ready to be scripted. */
            YAHOO.util.Event.onDOMReady(function() {

    	        if (document.URL.indexOf("http://") > -1) {
    				document.getElementById("serverTR").style.display = "none";
    	        }
    	        
    	        YAHOO.DeployManager.container.loginDialog.callback = {
          			  success: function(o) { 
						  role = o.responseText;
			  		
    	        		  YAHOO.DeployManager.container.loginDialog.dialog.hide();
    	        		  YAHOO.DeployManager.container.waitDialog.dialog.hide();

    	        		  var idx = YAHOO.DeployManager.container.menubar.getItems().length -1 ;
    	        		  YAHOO.DeployManager.container.menubar.getItem(idx).cfg.setProperty("text", "Loggato come " + role);
        			   	}, 
        			  failure: function(o) {
        			   		YAHOO.DeployManager.container.loginDialog.dialog.show();
        			   		YAHOO.DeployManager.container.waitDialog.dialog.hide();
        			   		onErrorMessage("Username e/o password errate");
             			}
            	};
            	
    	        YAHOO.DeployManager.container.loginDialog.handleLoginSubmit = function() {   		
    	        	var input = YAHOO.DeployManager.container.loginDialog.dialog.body.getElementsByTagName("input");
    	    		username = input[0].value;
    	    		password = input[1].value;
					
    	    		if (password == null || password == "")
        	    		password = YAHOO.util.Cookie.get("password");
    	    		
    	    		if (input[2].checked) {
    	    			YAHOO.util.Cookie.set("username", username, { expires: new Date("January 12, 2025") });
    	    			YAHOO.util.Cookie.set("password", password, { expires: new Date("January 12, 2025") });
    	    			YAHOO.util.Cookie.set("rempassword", "true", { expires: new Date("January 12, 2025") });   
    	    		} else {
    	    			YAHOO.util.Cookie.remove("username"); 
    	    			YAHOO.util.Cookie.remove("password"); 
    	    			YAHOO.util.Cookie.remove("rempassword"); 
    	    		}
					
    	    		var request = YAHOO.util.Connect.asyncRequest("GET", server + "manager/userroles" , YAHOO.DeployManager.container.loginDialog.callback);
    	    		YAHOO.DeployManager.container.waitDialog.dialog.show();
        			YAHOO.DeployManager.container.loginDialog.dialog.hide();

        			YAHOO.util.Connect.setDefaultPostHeader(true);
    	    	};
    	    	
    	    	YAHOO.DeployManager.container.menubar = new YAHOO.widget.MenuBar("menubar");
    	    	YAHOO.DeployManager.container.menubar.render(document.body);
             	
                YAHOO.DeployManager.container.manager = new YAHOO.widget.OverlayManager();

                YAHOO.DeployManager.container.loginDialog.dialog = new YAHOO.widget.Dialog("loginDialog", 
                    { close: false, visible:false, width:"300px", modal: true
                        , buttons: [ { text:"Accedi", handler: YAHOO.DeployManager.container.loginDialog.handleLoginSubmit, isDefault:true } ] } ); 
                YAHOO.DeployManager.container.loginDialog.dialog.render();
                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.loginDialog.dialog);
     
                YAHOO.DeployManager.container.waitDialog.dialog = new YAHOO.widget.Panel("waitDialog", 
					{ width: "240px", fixedcenter: true, close: false, draggable: false,
                      zindex:4, modal: true, visible: false });
                YAHOO.DeployManager.container.waitDialog.dialog.render();
                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.waitDialog.dialog);

                YAHOO.DeployManager.container.errorMessageDialog.dialog = new YAHOO.widget.Dialog("errorMessageDialog", 
                        { width:"320px", visible:false, draggable:true, close:false, fixedcenter : true, 
                            constraintoviewport : true, zIndex: 1, modal : true, 
                            buttons : [ { text:"Ok", handler: function() {YAHOO.DeployManager.container.errorMessageDialog.dialog.hide(); }, isDefault:true } ] } );
                YAHOO.DeployManager.container.errorMessageDialog.dialog.render();
                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.errorMessageDialog.dialog);

                YAHOO.DeployManager.container.promptDialogForm.dialog = new YAHOO.widget.Dialog("promptDialogForm", 
                        { width:"320px", visible:false, draggable:true, close:false, fixedcenter : true, 
                            constraintoviewport : true, zIndex: 1, modal : true, 
                            buttons : [ { text:"Ok", isDefault:true }, 
                                        { text:"Annulla", isDefault:true },] } ); 
                YAHOO.DeployManager.container.promptDialogForm.dialog.render();
                YAHOO.DeployManager.container.promptDialogForm.dialog.getButtons()[0].subscribe("click", function() { YAHOO.DeployManager.container.promptDialogForm.dialog.hide(); }); 
                YAHOO.DeployManager.container.promptDialogForm.dialog.getButtons()[1].subscribe("click", function() { YAHOO.DeployManager.container.promptDialogForm.dialog.hide(); });  
                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.promptDialogForm.dialog);
                YAHOO.util.Event.addListener(document.getElementById("promptDialogForm_Name"), "keyup", YAHOO.DeployManager.container.promptDialogForm.checkChart);
                
                YAHOO.DeployManager.container.alertDialog.dialog = new YAHOO.widget.Dialog("alertDialog", 
                        { width:"320px", visible: false, draggable: true, close:false, fixedcenter: true, 
                            constraintoviewport: true, zIndex: 1, modal: true, 
                            buttons : [ { text:"Si", isDefault: true },
                                        { text:"No", isDefault: false } ] } );
                YAHOO.DeployManager.container.alertDialog.dialog.render();
                YAHOO.DeployManager.container.alertDialog.dialog.getButtons()[0].subscribe("click", function() { YAHOO.DeployManager.container.alertDialog.dialog.hide(); }); 
                YAHOO.DeployManager.container.alertDialog.dialog.getButtons()[1].subscribe("click", function() { YAHOO.DeployManager.container.alertDialog.dialog.hide(); });
                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.alertDialog.dialog);
                
                YAHOO.DeployManager.container.loginDialog.dialog.show();
                YAHOO.DeployManager.container.loginDialog.dialog.center(); 

                //restoro i dati di accesso
                //Restore from cookie (con getData() della Dialog non va) DA CONTROLLARE
                var input = YAHOO.DeployManager.container.loginDialog.dialog.body.getElementsByTagName("input");
                if (YAHOO.util.Cookie.get("username") != null) input[0].value = YAHOO.util.Cookie.get("username");
                if (YAHOO.util.Cookie.get("password") != null) input[1].value = YAHOO.util.Cookie.get("password");
                if (YAHOO.util.Cookie.get("rempassword") == "true") {
                    input[2].checked = true;
                } 
                
                //se si clicca sul titolo di una finestra nascondo i menu...
				YAHOO.util.Event.on(YAHOO.DeployManager.container.loginDialog.dialog.element, "mousedown", 
						YAHOO.DeployManager.container.menubar.clearActiveItem, null, YAHOO.DeployManager.container.menubar);

                //Configuro il menu
                var idx = YAHOO.DeployManager.container.menubar.getItems().length - 1;
				YAHOO.DeployManager.container.menubar.getItem(idx).cfg.setProperty("disabled", true);
				
            });


            

            /***********************************************************************************************/
            /***********************************************************************************************/
            /***********************    Codice delle finestre    *******************************************/
            /***********************************************************************************************/
            
            /******************************  ALERT *********************************************************/
            function onAlertMessage(message, callback, args) {
                YAHOO.DeployManager.container.alertDialog.dialog.setBody(message);
                YAHOO.DeployManager.container.alertDialog.dialog.show();        
                YAHOO.DeployManager.container.alertDialog.dialog.center(); 

                YAHOO.DeployManager.container.alertDialog.dialog.getButtons()[0].set("onclick", null);
                YAHOO.DeployManager.container.alertDialog.dialog.getButtons()[1].set("onclick", null);

                if (callback != null && callback.yes != null && callback.yes != undefined) {
                	YAHOO.DeployManager.container.alertDialog.dialog.getButtons()[0].set("onclick", callback.yes);
                }

                if (callback != null && callback.no != null && callback.no != undefined) {
                	YAHOO.DeployManager.container.alertDialog.dialog.getButtons()[1].set("onclick", callback.no);
                }
                
            };
            
            /******************************  Error message **************************************************/
            function onErrorMessage(message) {
                YAHOO.DeployManager.container.errorMessageDialog.dialog.setHeader("Errore");
                YAHOO.DeployManager.container.errorMessageDialog.dialog.setBody(message);
                YAHOO.DeployManager.container.errorMessageDialog.dialog.show();        
                YAHOO.DeployManager.container.errorMessageDialog.dialog.center(); 
            };

            /******************************Prompt per stringe***********************************************/
            onPromptMessage = function(title, callback, notValidChart) {
            	document.getElementById("promptDialogForm_Name").value = "";
            	YAHOO.DeployManager.container.promptDialogForm.dialog.setHeader(title);
            	YAHOO.DeployManager.container.promptDialogForm.dialog.show();
            	YAHOO.DeployManager.container.promptDialogForm.dialog.center();
            	
            	YAHOO.DeployManager.container.promptDialogForm.dialog.getButtons()[0].set("onclick", null);
                YAHOO.DeployManager.container.promptDialogForm.dialog.getButtons()[1].set("onclick", null);

                if (callback != null && callback.ok != null && callback.ok != undefined) {
                	YAHOO.DeployManager.container.promptDialogForm.dialog.getButtons()[0].set("onclick", callback.ok);
                }

                if (callback != null && callback.cancel != null && callback.cancel != undefined) {
                	YAHOO.DeployManager.container.promptDialogForm.dialog.getButtons()[1].set("onclick", callback.cancel);
                }
                YAHOO.DeployManager.container.promptDialogForm.notValidChart = notValidChart; 
                document.getElementById("promptDialogForm_Name").focus();                
            }

            YAHOO.DeployManager.container.promptDialogForm.checkChart = function() {
                var input = document.getElementById("promptDialogForm_Name");
                var notValidChart = YAHOO.DeployManager.container.promptDialogForm.notValidChart; 

            	if (notValidChart != undefined && notValidChart.constructor == Array) {
                    for (i in notValidChart) {
                        if (input.value.indexOf(notValidChart[i]) > -1)
                        	input.value = input.value.replace(notValidChart[i], "");
                    }
                }
            }
            
            /******************************* HELP ***************************************************/            
            YAHOO.DeployManager.container.HelpDialog.createAndShow = function() {
            	if (YAHOO.DeployManager.container.HelpDialog.dialog == null) {
	               	var html = '<div id="helpDialog">' + 
		                '<div class="hd">Help</div> ' +
		                '<div class="bd"> ' +
		                    '<iframe src="help.html" style="width: 100%; height: 100%;"/> ' +
		                 '</div>' + 
		              '</div>'; 
	
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
	                    
	                YAHOO.DeployManager.container.HelpDialog.dialog = new YAHOO.widget.Dialog("helpDialog",  
	                        { width: "450px", height: "500px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                YAHOO.DeployManager.container.HelpDialog.dialog.render();
	                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.HelpDialog.dialog);

	                var resize = new YAHOO.util.Resize("helpDialog", {
                        handles: ["br"], autoRatio: false, minWidth: 300, minHeight: 100, status: false } );

					  resize.on("startResize", function(args) {
						    if (this.cfg.getProperty("constraintoviewport")) {
					          var D = YAHOO.util.Dom;
					          var clientRegion = D.getClientRegion();
					          var elRegion = D.getRegion(this.element);
					          resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
					          resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
					      } else {
					          resize.set("maxWidth", null);
					          resize.set("maxHeight", null);
					  	}
					
					  }, YAHOO.DeployManager.container.HelpDialog.dialog, true);
					
					  resize.on("resize", function(args) {
					     	var panelHeight = args.height;
					     	this.cfg.setProperty("height", panelHeight + "px"); }, 
					      	YAHOO.DeployManager.container.HelpDialog.dialog, true);      
	
            	}
            	YAHOO.DeployManager.container.HelpDialog.dialog.center();
                YAHOO.DeployManager.container.HelpDialog.dialog.show();
            }

            /******************************* ENVIRONMENT ***************************************************/            
            YAHOO.DeployManager.container.EnvironmentDialog.createAndShow = function() {

            	if (YAHOO.DeployManager.container.EnvironmentDialog.dialog == null) {
	               	var html = '<div id="environmentDialog">' + 
		                '<div class="hd">Ambienti</div> ' +
		                '<div class="bd"> ' +
		                    '<div id="environmantDataTable"></div> ' +
		                 '</div>' + 
		              '</div>'; 
	
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
	                    
	                YAHOO.DeployManager.container.EnvironmentDialog.dialog = new YAHOO.widget.Dialog("environmentDialog",  
	                        { width: "350px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Aggiungi", handler: YAHOO.DeployManager.container.EnvironmentDialog.newRow, isDefault: false },
	                                      { text: "Elimina", handler: YAHOO.DeployManager.container.EnvironmentDialog.delRow, isDefault: false },
	       	                              { text: "Ok", handler: YAHOO.DeployManager.container.EnvironmentDialog.ok, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                YAHOO.DeployManager.container.EnvironmentDialog.dialog.render();
	                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.EnvironmentDialog.dialog);
	                YAHOO.DeployManager.container.EnvironmentDialog.dialog.getButtons()[1].set("disabled", true);

	                var resize = new YAHOO.util.Resize("environmentDialog", {
		                                  handles: ["br"], autoRatio: false, minWidth: 300, minHeight: 100, status: false } );

	                resize.on("startResize", function(args) {
	        		    if (this.cfg.getProperty("constraintoviewport")) {
	                        var D = YAHOO.util.Dom;
	                        var clientRegion = D.getClientRegion();
	                        var elRegion = D.getRegion(this.element);
	                        resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
	                        resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
	    	            } else {
	                        resize.set("maxWidth", null);
	                        resize.set("maxHeight", null);
	    	        	}

	                }, YAHOO.DeployManager.container.EnvironmentDialog.dialog, true);

	                resize.on("resize", function(args) {
	                    		var panelHeight = args.height;
	                    		this.cfg.setProperty("height", panelHeight + "px"); }, 
	                    	YAHOO.DeployManager.container.EnvironmentDialog.dialog, true);                
	                
	                var myColumnDefs = [ 
	            		{ key:"name", label: "Nome", sortable:true, resizeable:true },  
	            		{ key:"numVirtualHost", label: "Numero Virtual Hosts", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true } ]; 

	                var myDataSource = new YAHOO.util.DataSource(server + "manager/environment");
	                myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
	                myDataSource.responseSchema = { resultNode: "environment", fields: ["name",{key:"numVirtualHost",parser:"number"} ] };
	                YAHOO.DeployManager.container.EnvironmentDialog.datasource = myDataSource;
	                
			        var myDataTable = new YAHOO.widget.DataTable("environmantDataTable", myColumnDefs, myDataSource, {selectionMode: "single"}); 
			        myDataTable.getTableEl().width = "100%";

			        myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow); 
			        myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);  
			        myDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.EnvironmentDialog.onEventSelectRow); 
			        YAHOO.DeployManager.container.EnvironmentDialog.datatable = myDataTable;

			        YAHOO.DeployManager.container.EnvironmentDialog.refresh = function () {
			           	YAHOO.DeployManager.container.EnvironmentDialog.datatable.getDataSource().sendRequest(
		           			YAHOO.DeployManager.container.EnvironmentDialog.datatable._request,
		           			YAHOO.DeployManager.container.EnvironmentDialog.datatable.onDataReturnInitializeTable,
		            		YAHOO.DeployManager.container.EnvironmentDialog.datatable
		            	); 
			        }
			        
            	}

            	YAHOO.DeployManager.container.EnvironmentDialog.refresh();
            	YAHOO.DeployManager.container.EnvironmentDialog.dialog.center();
                YAHOO.DeployManager.container.EnvironmentDialog.dialog.show();
            }

            YAHOO.DeployManager.container.EnvironmentDialog.onEventSelectRow = function(o) {	
            	YAHOO.DeployManager.container.EnvironmentDialog.dialog.getButtons()[1].set("disabled", false);
            	YAHOO.DeployManager.container.EnvironmentDialog.datatable.onEventSelectRow(o);
            }
            
            YAHOO.DeployManager.container.EnvironmentDialog.ok = function() {
            	YAHOO.DeployManager.container.EnvironmentDialog.dialog.hide();
            }
            
            YAHOO.DeployManager.container.EnvironmentDialog.delRow = function() {
            	var recordSel = YAHOO.DeployManager.container.EnvironmentDialog.datatable.getSelectedRows()[0];
       	       	var record = YAHOO.DeployManager.container.EnvironmentDialog.datatable.getRecord(recordSel);

            	onAlertMessage("Sicuro di voler eliminare l'ambiente " + record.getData("name") + " e tutti i suoi virtual host?", { 
                	yes: {
                		  fn: function(o) {
	                  			var env = new BussinessObject.Environment(record.getData("name"));
	                			env.setToDelete(true);
	                			BussinessMethos.saveEnvironment(env); 
	                			YAHOO.DeployManager.container.EnvironmentDialog.datatable.deleteRow(recordSel);
	                		}, 
                		  obj: record
                		}                      	
            	} );
            }

            YAHOO.DeployManager.container.EnvironmentDialog.newRow = function() {
            	onPromptMessage("Nuovo Ambiente", { 
                	ok: {
                		fn: function(o) {
		                    //send update
		                    var env = new BussinessObject.Environment();
		                    env.setName(document.getElementById("promptDialogForm_Name").value);
		                    BussinessMethos.saveEnvironment(env);
		
		                	//refresh parent's dialog
		                	YAHOO.DeployManager.container.EnvironmentDialog.refresh(); 
            			}
                	} 
            	}, new Array(" ", "-") );
            }
            
            
            /******************************* WEB APPLICATION ************************************************/
            YAHOO.DeployManager.container.WebAppsDialog.createAndShow = function() {
                
				if (YAHOO.DeployManager.container.WebAppsDialog.dialog == null) {
	               	var html = '<div id="webappsDialog">' + 
		                '<div class="hd">Web Applications</div> ' +
		                '<div class="bd"> ' +
		                    '<div id="webappsDataTable" style="width: 685px; height: 290px;"></div> ' +
		                 '</div>' + 
		              '</div>'; 
		
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
		                    
		            YAHOO.DeployManager.container.WebAppsDialog.dialog = new YAHOO.widget.Dialog("webappsDialog",  
	                        { width: "700px", height: "400px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Nuovo deploy", handler: YAHOO.DeployManager.container.WebAppsDialog.deploy, isDefault: false },
	        	                          { text: "Log ultimo deploy", handler: YAHOO.DeployManager.container.WebAppsDialog.viewlastlog, isDefault: false },
	                                      { text: "Redeploy", handler: YAHOO.DeployManager.container.WebAppsDialog.redeploy, isDefault: false },
	                                      { text: "Undeploy", handler: YAHOO.DeployManager.container.WebAppsDialog.undeploy, isDefault: false },
	       	                              { text: "Ok", handler: YAHOO.DeployManager.container.WebAppsDialog.ok, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                YAHOO.DeployManager.container.WebAppsDialog.dialog.render();
	                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.WebAppsDialog.dialog);
	                YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[1].set("disabled", true);
	                YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[2].set("disabled", true);
	                YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[3].set("disabled", true);

	                var resize = new YAHOO.util.Resize("webappsDialog", {
		                                  handles: ["br"], autoRatio: false, minWidth: 300, minHeight: 100, status: false } );

	                resize.on("startResize", function(args) {
	        		    if (this.cfg.getProperty("constraintoviewport")) {
	                        var D = YAHOO.util.Dom;
	                        var clientRegion = D.getClientRegion();
	                        var elRegion = D.getRegion(this.element);
	                        resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
	                        resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
	    	            } else {
	                        resize.set("maxWidth", null);
	                        resize.set("maxHeight", null);
	    	        	}

	               	}, YAHOO.DeployManager.container.WebAppsDialog.dialog, true);
	
		            resize.on("resize", function(args) {
			            	var D = YAHOO.util.Dom;
							var panelHeight = args.height;
							var panelWidth = args.width;
			                this.cfg.setProperty("height", panelHeight + "px");
			                YAHOO.DeployManager.container.WebAppsDialog.datatable.set("width", panelWidth - 15 + "px");
			                YAHOO.DeployManager.container.WebAppsDialog.datatable.set("height", panelHeight - 111 + "px");
		             	}, 
		             YAHOO.DeployManager.container.WebAppsDialog.dialog, true);                
		                
					var myColumnDefs = [ 
	            		{ key:"environment", label: "Ambiente", sortable:true, resizeable:true, maxAutoWidth: 67 },  
	            		{ key:"virtualhost", label: "Virtual Host", sortable:true, resizeable:true, maxAutoWidth: 92 },
	            		{ key:"name", label: "Nome", sortable:true, resizeable:true, maxAutoWidth: 58 },
	            		{ key:"lastdeploy", label: "Ultimo deploy", sortable:true, resizeable:true, maxAutoWidth: 93 },
	            		{ key:"status", label: "Stato", sortable:true, resizeable:true, maxAutoWidth: 267 } ]; 
	
		            var myDataSource = new YAHOO.util.DataSource(server + "manager/webapp");
		            myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
		            myDataSource.responseSchema = { resultNode: "webapp", fields: ["environment", "virtualhost", "name", "lastdeploy", "status" ] };
		            YAHOO.DeployManager.container.WebAppsDialog.datasource = myDataSource;
		                
				    var myDataTable = new YAHOO.widget.ScrollingDataTable("webappsDataTable", myColumnDefs, myDataSource, 
						    {selectionMode: "single", height: "100%" }); 
	
				    myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow); 
				    myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);  
				    myDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.WebAppsDialog.onEventSelectRow); 
				    myDataTable.subscribe("rowDblclickEvent", YAHOO.DeployManager.container.WebAppsDialog.onDblclickRow);
				    YAHOO.DeployManager.container.WebAppsDialog.datatable = myDataTable;
	
				    YAHOO.DeployManager.container.WebAppsDialog.refresh = function () {
				       	YAHOO.DeployManager.container.WebAppsDialog.datatable.getDataSource().sendRequest(
			        		YAHOO.DeployManager.container.WebAppsDialog.datatable._request,
			        		YAHOO.DeployManager.container.WebAppsDialog.datatable.onDataReturnInitializeTable,
			        		YAHOO.DeployManager.container.WebAppsDialog.datatable
			        	); 
				    }
				}

			 	YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[1].set("disabled", true);
	        	YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[2].set("disabled", true);
	        	YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[3].set("disabled", true);
            	YAHOO.DeployManager.container.WebAppsDialog.refresh();
                YAHOO.DeployManager.container.WebAppsDialog.dialog.show();
                YAHOO.DeployManager.container.WebAppsDialog.dialog.center();
                YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.WebAppsDialog.dialog);
            }
            
            YAHOO.DeployManager.container.WebAppsDialog.onDblclickRow = function(o) {
            	var record = YAHOO.DeployManager.container.WebAppsDialog.datatable.getRecord(o.target);
            	var env = record.getData("environment");
            	var vh = record.getData("virtualhost");
            	var name = record.getData("name");
            	YAHOO.DeployManager.container.WebappStatusDialog.createAndShow(env, vh, name);
            }
            
	        YAHOO.DeployManager.container.WebAppsDialog.onEventSelectRow = function(o) {	
	        	YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[1].set("disabled", false);
	        	YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[2].set("disabled", false);
	        	YAHOO.DeployManager.container.WebAppsDialog.dialog.getButtons()[3].set("disabled", false);
	        	YAHOO.DeployManager.container.WebAppsDialog.datatable.onEventSelectRow(o);
	        }
	            
	        YAHOO.DeployManager.container.WebAppsDialog.ok = function() {
	        	YAHOO.DeployManager.container.WebAppsDialog.dialog.hide();
	        }

	        YAHOO.DeployManager.container.WebAppsDialog.viewlastlog = function() {
	        	var recordSel = YAHOO.DeployManager.container.WebAppsDialog.datatable.getSelectedRows()[0];
       	       	var record = YAHOO.DeployManager.container.WebAppsDialog.datatable.getRecord(recordSel);
       	       	
	        	var querystring = "DeployDialogEnvironment=" + record.getData("environment") + "&";
            	querystring += "DeployDialogVirtualHost=" + record.getData("virtualhost") + "&";
            	querystring += "DeployDialogContext=" + record.getData("name") + "&";
            	querystring += "OnlyView=true";
            	YAHOO.DeployManager.container.DeployLogDialog.createAndShow(querystring);
	        }
	        
            YAHOO.DeployManager.container.WebAppsDialog.deploy = function() {
            	YAHOO.DeployManager.container.DeployDialog.createAndShow();
            }

            YAHOO.DeployManager.container.WebAppsDialog.redeploy = function() {
            	var recordSel = YAHOO.DeployManager.container.WebAppsDialog.datatable.getSelectedRows()[0];
       	       	var record = YAHOO.DeployManager.container.WebAppsDialog.datatable.getRecord(recordSel);
				var env = record.getData("environment"); 
				var vh = record.getData("virtualhost");
				var name = record.getData("name");
       	       	var webapp = new BussinessObject.WebApp(env + "," + vh.replace(new RegExp("\\.", "gi"), ":") + "," + name);
       	     	YAHOO.DeployManager.container.DeployDialog.createAndShow(webapp);
            }
            
            YAHOO.DeployManager.container.WebAppsDialog.undeploy = function() {
            	var recordSel = YAHOO.DeployManager.container.WebAppsDialog.datatable.getSelectedRows()[0];
       	       	var record = YAHOO.DeployManager.container.WebAppsDialog.datatable.getRecord(recordSel);

            	onAlertMessage("Sicuro di voler fare l'undeploy della " + record.getData("name") + " ?", { 
                	yes: {
                		  fn: function(o) {
			        			var querystring = "DeployDialogEnvironment=" + record.getData("environment") + "&";
			                	querystring += "DeployDialogVirtualHost=" + record.getData("virtualhost") + "&";
			                	querystring += "DeployDialogContext=" + record.getData("name");
			                	BussinessMethos.UndeployWebApp(record.getData("environment"), record.getData("virtualhost"), record.getData("name"));
			                	YAHOO.DeployManager.container.DeployLogDialog.createAndShow(querystring);
			                	YAHOO.DeployManager.container.WebAppsDialog.datatable.deleteRow(recordSel);    
	                		}, 
                		  obj: record
                		}                      	
            	} );
            }

            /******************************* WEBAPP STATUS DIALOG ***********************************************/
            YAHOO.DeployManager.container.WebappStatusDialog.createAndShow = function(environment, virtualhost, webapp) {

            	var vh = environment + "," + virtualhost.replace(new RegExp("\\.", "gi"), ":");
            	var id = vh + "," + webapp
                var dialog;

                var measures = BussinessMethos.getChartSet();
                
            	if (YAHOO.DeployManager.container.WebappStatusDialog.dialog[id] == undefined) {
                	
	        		var html = '<div id="WebappStatusDialog'+id+'">' + 
		                '<div class="hd">Stato WebApp '+ environment +' / ' + virtualhost + ' / ' + webapp + '</div>' +
		                '<div class="bd" style="overflow: auto"> ' +
	                    	'<label style="display: block;">Selezionare l\'intervallo da visualizzare:</label>' +
	                    	'<fieldset id="WebappStatusDialogRadioButton'+id+'"></fieldset>' +
		                 '</div>' + 
		              '</div>'; 
		            var elDiv = document.createElement("div");
		            elDiv.innerHTML = html;
		            document.body.appendChild(elDiv); 

		            var virtualhost = new BussinessObject.VirtualHost(vh);
		            
		            var elDiv;
            		var node = YAHOO.util.Dom.getChildren(YAHOO.util.Dom.getChildren(elDiv)[0])[1];
					var nodes = evalutateXPath(measures, "list/Measure");           	
	            	for (var i = 0; i < nodes.length; i++) {

	            		var jmxs = evalutateXPath(virtualhost.getJMXServersToMonitor(), "string");
	            		for (var z = 0; z < jmxs.length; z++) {
		            		var server =  getContentInElement(jmxs[z]);
		            	
		            		var idm = getContentInElement(evalutateXPath(nodes[i],"id")[0]);
		            		var name = getContentInElement(evalutateXPath(nodes[i],"name")[0]);
		            		var level = getContentInElement(evalutateXPath(nodes[i],"level")[0]);
		            		name = name + " (" + level + ")";
	
		            		elDiv = document.createElement("div");
		            		elDiv.setAttribute("idm", idm);
		            		elDiv.setAttribute("server", server);
		             		elDiv.style.width = "100%";
		            		elDiv.style.border  = "3px solid #426FD9";
		            		elDiv.style.borderBottomWidth = "0px";
		            		elDiv.innerHTML = "<label style='display: block;'>" + name + " on " + server + "</label><div style='width: 100%; height: 1px;'/>";
		            		node.appendChild(elDiv);
		            		 
		            		YAHOO.util.Event.on(elDiv, 'click', function (event) {
			            		var div = event.target;
			            		if (div.getAttribute("idm") == null)
			            			div = div.parentNode;
			            		if (div == null)
				            		return;
	 
			            		var idm = div.getAttribute("idm");
			            		var server = div.getAttribute("server"); 
			            		var divChart = YAHOO.util.Dom.getChildren(div)[1];
			            		
			            		var isopen = div.getAttribute("isopen");
			            		if (isopen != null) {
									if (isopen == "true") {
										div.setAttribute("isopen", "false");
										divChart.style.height = "0px";
									} else {
										div.setAttribute("isopen", "true");
										divChart.style.height = "250px";
									}
				            		return;
			            		}
			            		
			            		div.setAttribute("isopen", "true");
			            		divChart.style.height = "200px";
					            YAHOO.widget.Chart.SWFURL = "yui/build/charts/assets/charts.swf";
	
					        	var myDataSource = new YAHOO.util.DataSource( "services/Chartdata/"+id+","+idm+","+ 
					        			YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].range + "," + server.replace(new RegExp("\\.", "gi"), ":") );
					        	myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
						        myDataSource.responseSchema = { resultNode: "c", fields: ["dt"] };					        
						        YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].datasources.push(myDataSource);
						        
						    	var seriesDef = new Array();
					        	var preview = BussinessMethos.getDataPreview("services/Chartset/"+id+","+idm+",1h,"+server.replace(new RegExp("\\.", "gi"), ":") );
					        	var nodes = evalutateXPath(preview, "list/name");           	
				            	for (var i = 0; i < nodes.length; i++) {
				            		var name = getContentInElement(nodes[i]);
				            		myDataSource.responseSchema.fields.push(name);
				            		seriesDef[i] = {};
				            		seriesDef[i].displayName = name;
				            		seriesDef[i].yField = name;
				            	}
					             
					        	var yAxis = new YAHOO.widget.NumericAxis();
					        	var mychart = new YAHOO.widget.LineChart(divChart, myDataSource, { 
						        	xField: "dt",
						        	series: seriesDef,
					        		polling: 60000,
					        		wmode: "opaque",
					        		expressInstall: "assets/expressinstall.swf",
				        			style: { padding: 10, legend: { display: "right", padding: 5, spacing: 5, font: { family: "Arial", size: 13 } } }
					        	});
					        	YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].charts.push(mychart);
					        	
		            		});
	            		}
	            	}
	            	elDiv.style.borderBottomWidth = "3px";
	            	
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id] = {};
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].range = "1h";
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].datasources = new Array();
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].charts = new Array();
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].radiofieldWebappStatus = new YAHOO.widget.ButtonGroup ( { 
				        id:"WebappStatusDialogRadioButtonID" + id, name: "radiofieldWebappStatus", 
				        container:  "WebappStatusDialogRadioButton" + id, usearia: true });

		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].radiofieldWebappStatus.addButtons([
			            { label: "1 Ora", value: "1h", checked: true },
			            { label: "6 Ore", value: "6h" },
			            { label: "12 Ore", value: "12h" },
			            { label: "1 Giorno", value: "1d" },
			            { label: "2 Giorni", value: "2d" },
			            { label: "Tutto", value: "all" }
			        ]);
			        
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].radiofieldWebappStatus.on("checkedButtonChange", function(o) {
			            var dialog = YAHOO.DeployManager.container.WebappStatusDialog.dialog[id];
		            	dialog.range = o.newValue.get("value");
		            	
		            	for (var i = 0; i < dialog.datasources.length; i++) {
			            	var ds = dialog.datasources[i];
			            	ds.liveData = ds.liveData.replace(","+o.prevValue.get("value")+",", ","+dialog.range+",");
		            	}
		            	
		            	for (var i = 0; i < dialog.charts.length; i++) {
			            	var chart = dialog.charts[i];
			            	chart.refreshData();
		            	}
			        });

		            dialog = new YAHOO.widget.Dialog("WebappStatusDialog" + id,  
		                    { width: "500px", height: "500px", autoScroll: "true", fixedcenter: false, close: true, draggable: true, modal: false, 
	                    		visible: false, zIndex: 2, autofillheight: "body",
		                      effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
		            YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].dialog = dialog;

	                var resize = new YAHOO.util.Resize("WebappStatusDialog" + id, {
                        handles: ["br"], autoRatio: false, minWidth: 400, minHeight: 300, status: false } );
				
				  	resize.on("startResize", function(args) {
					    if (this.cfg.getProperty("constraintoviewport")) {
				          var D = YAHOO.util.Dom;
				          var clientRegion = D.getClientRegion();
				          var elRegion = D.getRegion(this.element);
				          resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
				          resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
				        } else {
				          resize.set("maxWidth", null);
				          resize.set("maxHeight", null);
					  	}
					
					  }, YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].dialog, true);
				
				  	resize.on("resize", function(args) {
				      		var panelHeight = args.height;
				      		var panelWidth = args.width;
				      		this.cfg.setProperty("height", panelHeight + "px");
				      	 }, YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].dialog, true);                

		            dialog.render();
		            YAHOO.DeployManager.container.manager.register(dialog);
		              
            	} else {
            		dialog = YAHOO.DeployManager.container.WebappStatusDialog.dialog[id].dialog;
            	}

	            dialog.center();
	            dialog.show();
	            YAHOO.DeployManager.container.manager.focus(dialog);

            } 
            
            /******************************* DEPLOY LOG DIALOG ***********************************************/
            YAHOO.DeployManager.container.DeployLogDialog.createAndShow = function(querystring) {
            	if (YAHOO.DeployManager.container.DeployLogDialog.lastid == undefined)
            		YAHOO.DeployManager.container.DeployLogDialog.lastid = 1;
            	else
            		YAHOO.DeployManager.container.DeployLogDialog.lastid = YAHOO.DeployManager.container.DeployLogDialog.lastid + 1;
        		var id = YAHOO.DeployManager.container.DeployLogDialog.lastid;

        		var html = '<div id="DeployLogDialog'+id+'">' + 
	                '<div class="hd">Deploy Log</div> ' +
	                '<div class="bd" style="overflow: auto;"> ' +
	                	'<textarea style="width: 99%; height: 98%;" id="DeployLogDialogText'+id+'"></textarea>' +
	                 '</div>' + 
	              '</div>'; 
	
	            var elDiv = document.createElement("div");
	            elDiv.innerHTML = html;
	            document.body.appendChild(elDiv); 
	                
	            YAHOO.DeployManager.container.DeployLogDialog.dialog[id] = new YAHOO.widget.Dialog("DeployLogDialog" + id,  
	                    { width: "650px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                      effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );

                var resize = new YAHOO.util.Resize("DeployLogDialog" + id, {
                    handles: ["br"], autoRatio: false, minWidth: 400, minHeight: 300, status: false } );
			
			  	resize.on("startResize", function(args) {
				    if (this.cfg.getProperty("constraintoviewport")) {
			          var D = YAHOO.util.Dom;
			          var clientRegion = D.getClientRegion();
			          var elRegion = D.getRegion(this.element);
			          resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
			          resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
			        } else {
			          resize.set("maxWidth", null);
			          resize.set("maxHeight", null);
				  	}
				
				  }, YAHOO.DeployManager.container.DeployLogDialog.dialog[id], true);
			
			  	resize.on("resize", function(args) {
			      		var panelHeight = args.height;
			      		var panelWidth = args.width;
			      		this.cfg.setProperty("height", panelHeight + "px");
			      	 }, YAHOO.DeployManager.container.DeployLogDialog.dialog[id], true);     
		      	 

	            YAHOO.DeployManager.container.DeployLogDialog.dialog[id].render();
	            YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.DeployLogDialog.dialog[id]);  
	            YAHOO.DeployManager.container.DeployLogDialog.dialog[id].center();
	            YAHOO.DeployManager.container.DeployLogDialog.dialog[id].show();
	            YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.DeployLogDialog.dialog[id]);

	            var xhr = YAHOO.util.Connect.createXhrObject();
	    		var conn = xhr.conn;
	    		YAHOO.DeployManager.container.DeployLogDialog.dialog[id].conn = conn;
	    		
	    		conn.open("GET", server + 'services/Deployer?' + querystring, true);
	    		YAHOO.util.Connect.setHeader(xhr);
	    		conn.send(null);

	    		var timeoutid = setInterval('YAHOO.DeployManager.container.DeployLogDialog.refresh('+id+')', 200);
	    		YAHOO.DeployManager.container.DeployLogDialog.dialog[id].timeoutid = timeoutid;
            } 
            
        	YAHOO.DeployManager.container.DeployLogDialog.refresh = function(id) {
	    		var conn = YAHOO.DeployManager.container.DeployLogDialog.dialog[id].conn;
				var timeoutid = YAHOO.DeployManager.container.DeployLogDialog.dialog[id].timeoutid;
				var area = document.getElementById("DeployLogDialogText" + id);
				 
    			area.value = conn.responseText;
				area.scrollTop = area.scrollHeight;
				
    			if (conn.readyState == 4) {
    				clearTimeout(timeoutid);
					YAHOO.DeployManager.container.WebAppsDialog.refresh();
    			}
    		}
    		
            /******************************* DEPLOY DIALOG ***************************************************/
            YAHOO.DeployManager.container.DeployDialog.createAndShow = function(webapp) {

            	if (YAHOO.DeployManager.container.DeployDialog.dialog == null) {
	               	var html = '<div id="DeployDialog">' + 
		                '<div class="hd">Deploy</div> ' +
		                '<div class="bd"> ' +
		                	'<form enctype="multipart/form-data" method="post" action="'+server+'services/Deployer" id="sendDeploy" name="sendDeploy">' +
			                	'<div id="DeployDialog_Tab1">' +
			                		'<label>Selezionare il virtual host su cui deployare:</label><br/>' +
			                    	'<div id="deployDataTable" style="width: 100%; padding-top: 8px;"></div> ' +
			                    '</div>' +
			                    '<div id="DeployDialog_Tab2" style="display: none;">' +
			                    	'<label style="display: block;">Inserire il contesto dell\'applicazione web:</label><br/>' +
			                    	'<input style="width: 99%;" type="text" id="DeployDialogContext" name="DeployDialogContext"></input>' +
			                    	'<label style="display: block; padding-top: 15px;">Selezionare il metodo con cui deployare:</label><br/>' +
			                    	'<fieldset id="DeployDialogRadioButton" style="padding: 10px;"></fieldset>' +
			                    '</div>' +
			                    '<div id="DeployDialog_Tab31" style="display: none; text-align: center;">' +
			                    	'<label style="display: block; padding: 16px;">Upload del war:</label>' +
			                    	'<input style="display: block; " name="warfile" size="41" type="file"></input>' +
			                    	'<label style="display: block; padding: 16px;"></label>' +
		                    	'</div>' +
		                    	'<div id="DeployDialog_Tab32" style="display: none;">' +
			                    	'<label style="display: block;" >Estremi del Repository e comando di build</label><br/>' +
			                    	'<label style="display: block; width: 45%; float: left; text-align: left;">Working Directoty:</label>' + 
			                    	'<input style="width: 99%;" type="text" id="DeployDialogWorkingDir" name="DeployDialogWorkingDir"></input>' +
			                    	'<label style="display: block; width: 45%; float: left; text-align: left;">Comando per l\'SCM:</label>' + 
			                    	'<input style="width: 99%;" type="text" id="DeployDialogSCMCommand" name="DeployDialogSCMCommand"></input>' +
			                    	'<label style="display: block; width: 45%; float: left; text-align: left;">Comando di build:</label>' + 
			                    	'<input style="width: 99%;" type="text" id="DeployDialogBuildCommand" name="DeployDialogBuildCommand"></input>' +
			                    	'<label style="display: block; width: 45%; float: left; text-align: left;">Percorso dell\'artefatto:</label>' + 
			                    	'<input style="width: 99%;" type="text" id="DeployDialogPathArtifact" name="DeployDialogPathArtifact"></input>' +
		                    	'</div>' +
		                    	'<div id="DeployDialog_Tab4" style="display: none;">' +
		                    		'<label style="display: block;" >Upload delle informazioni in corso...</label><br/>' +
		                    	'</div>' +
		                    	'<input type="hidden" name="DeployDialogEnvironment" id="DeployDialogEnvironment">' +
		                    	'<input type="hidden" name="DeployDialogVirtualHost" id="DeployDialogVirtualHost">' +
		                    	'<input type="hidden" name="DeployDialogDeploymentType" id="DeployDialogDeploymentType">' +
		                    	'<input type="hidden" name="DeployDialogIsRedeploy" id="DeployDialogIsRedeploy" value="false">' +
		                    '</form>' +
		                 '</div>' + 
		              '</div>'; 
	
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
	                    
	                YAHOO.DeployManager.container.DeployDialog.dialog = new YAHOO.widget.Dialog("DeployDialog",  
	                        { width: "450px", fixedcenter: false, close: true, draggable: true, modal: true, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Annulla", handler: YAHOO.DeployManager.container.DeployDialog.cancel, isDefault: false },
	                                      { text: "< Indietro", handler: YAHOO.DeployManager.container.DeployDialog.back, isDefault: false },
	                                      { text: "Avanti >", handler: YAHOO.DeployManager.container.DeployDialog.next, isDefault: false },
	       	                              { text: "Deploy", handler: YAHOO.DeployManager.container.DeployDialog.deploy, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                YAHOO.DeployManager.container.DeployDialog.dialog.render();
	                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.DeployDialog.dialog);           
	                
	                var myColumnDefs = [ 
	            		{ key:"environment", label: "Ambiente", sortable:true, resizeable:true },  
	            		{ key:"name", label: "Virtual Host", sortable:true, resizeable:true } ]; 

	                var myDataSource = new YAHOO.util.DataSource(server + "manager/virtualhost");
	                myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
	                myDataSource.responseSchema = { resultNode: "virtualhost", fields: ["environment", "name", "numWebApps" ] };
	                YAHOO.DeployManager.container.DeployDialog.datasource = myDataSource;
	                
			        var myDataTable = new YAHOO.widget.ScrollingDataTable("deployDataTable", myColumnDefs, myDataSource, 
					        {selectionMode: "single", height: "8em" }); 
			        myDataTable.getTableEl().width = "100%";
			        YAHOO.DeployManager.container.DeployDialog.datatable = myDataTable;
 
			        YAHOO.DeployManager.container.DeployDialog.refresh = function () {
			           	YAHOO.DeployManager.container.DeployDialog.datatable.getDataSource().sendRequest(
		           			YAHOO.DeployManager.container.DeployDialog.datatable._request,
		           			YAHOO.DeployManager.container.DeployDialog.datatable.onDataReturnInitializeTable,
		            		YAHOO.DeployManager.container.DeployDialog.datatable
		            	); 
			        }

			        YAHOO.DeployManager.container.DeployDialog.setCurrentTab = function(index) {
	   	         		document.getElementById("DeployDialog_Tab1").style.display = "none";
	   	         		document.getElementById("DeployDialog_Tab2").style.display = "none";
	   	         		document.getElementById("DeployDialog_Tab31").style.display = "none";
	   	         		document.getElementById("DeployDialog_Tab32").style.display = "none";
	   	         		document.getElementById("DeployDialog_Tab4").style.display = "none";

		   	         	var tab;
				        if (index == 1) {
			   	         	tab = document.getElementById("DeployDialog_Tab1");
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[1].set("disabled", true);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", false);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[3].set("disabled", true);
				        } else if (index == 2) {
			        		tab = document.getElementById("DeployDialog_Tab2");
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[1].set("disabled", false);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", false);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[3].set("disabled", true);
				        } else if (index == 3) {
					        if (YAHOO.DeployManager.container.DeployDialog.deploymethod == "war") 
			        			tab = document.getElementById("DeployDialog_Tab31");
					        else
					    		tab = document.getElementById("DeployDialog_Tab32");
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[1].set("disabled", false);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", true);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[3].set("disabled", false);
				        } else {
				        	tab = document.getElementById("DeployDialog_Tab4");
				        	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[0].set("disabled", true);
			   	         	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[1].set("disabled", true);
			   	     		YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", true);
			   	 			YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[3].set("disabled", true);
				        }  
				        

				        tab.style.display = "block";
				        YAHOO.DeployManager.container.DeployDialog.currentTab = index; 
		        		
			        }

			        YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy = new YAHOO.widget.ButtonGroup ( { 
				        id:"buttongroup3", name: "radiofieldDeploy", container:  "DeployDialogRadioButton", usearia: true });

			        YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.addButtons([
			            { label: "Upload WAR", value: "war", checked: true },
			            { label: "Dal repository", value: "scm" } ] );
			        
			        YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.on("checkedButtonChange", function(o) {
			        	YAHOO.DeployManager.container.DeployDialog.deploymethod = o.newValue.get("value");
			        	document.getElementById("DeployDialogDeploymentType").value = YAHOO.DeployManager.container.DeployDialog.deploymethod;
			        });

			    	var oElement = document.getElementById("DeployDialogContext");
   					YAHOO.util.Event.addListener(oElement, "keyup", YAHOO.DeployManager.container.DeployDialog.checkContextName);

            	}

            	YAHOO.DeployManager.container.DeployDialog.dialog.setHeader("Nuovo deploy");
            	YAHOO.DeployManager.container.DeployDialog.setCurrentTab(1);
                YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[1].set("disabled", true);
                YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", true);
                YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[3].set("disabled", true); 
            	YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.check(0);
            	YAHOO.DeployManager.container.DeployDialog.deploymethod = "war";
            	YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.set("disabled", false);
                document.getElementById("DeployDialogDeploymentType").value = YAHOO.DeployManager.container.DeployDialog.deploymethod;                
                document.getElementById("DeployDialogEnvironment").value = ""; 
                document.getElementById("DeployDialogVirtualHost").value = "";
                document.getElementById("DeployDialogContext").value = "";
                document.getElementById("DeployDialogContext").readOnly = false;
                document.getElementById("DeployDialogPathArtifact").value = "";
                document.getElementById("DeployDialogPathArtifact").readOnly = false;
                document.getElementById("DeployDialogBuildCommand").value = "";
                document.getElementById("DeployDialogBuildCommand").readOnly = false;
                document.getElementById("DeployDialogSCMCommand").value = "";
                document.getElementById("DeployDialogSCMCommand").readOnly = false;
                document.getElementById("DeployDialogWorkingDir").value = "";   
                document.getElementById("DeployDialogWorkingDir").readOnly = false;  
                document.getElementById("DeployDialogIsRedeploy").value = "false";
                YAHOO.DeployManager.container.DeployDialog.datatable.unsubscribe("rowMouseoverEvent"); 
                YAHOO.DeployManager.container.DeployDialog.datatable.unsubscribe("rowMouseoutEvent");  
                YAHOO.DeployManager.container.DeployDialog.datatable.unsubscribe("rowClickEvent");
                YAHOO.DeployManager.container.DeployDialog.datatable.unsubscribe("postRenderEvent");
                  
                if (webapp != null || webapp != undefined) {
                    //è un redeploy
                    YAHOO.DeployManager.container.DeployDialog.dialog.setHeader("Redeploy");
                    
                    document.getElementById("DeployDialogIsRedeploy").value = "true";
                    YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", false);
	                document.getElementById("DeployDialogEnvironment").value = webapp.getEnvironment(); 
	                document.getElementById("DeployDialogVirtualHost").value = webapp.getVirtualHost();
	                document.getElementById("DeployDialogContext").value = webapp.getName();
	                document.getElementById("DeployDialogContext").readOnly = true;
	                document.getElementById("DeployDialogPathArtifact").value = webapp.getpathArtifact();
	                document.getElementById("DeployDialogPathArtifact").readOnly = true;
	                document.getElementById("DeployDialogBuildCommand").value = webapp.getBuildCommandCommand();
	                document.getElementById("DeployDialogBuildCommand").readOnly = true;
	                document.getElementById("DeployDialogSCMCommand").value = webapp.getSCMCommand();
	                document.getElementById("DeployDialogSCMCommand").readOnly = true;
	                document.getElementById("DeployDialogWorkingDir").value = webapp.getCurrentDirectory();
	                document.getElementById("DeployDialogWorkingDir").readOnly = true; 
	                YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.set("disabled", true);
	                
	                if (webapp.getDeployMode() == "WAR") {
	                	YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.check(0);
		            } else {
		            	YAHOO.DeployManager.container.DeployDialog.radiofieldDeploy.check(1);
		            }

					//selezione il record corretto
	                YAHOO.DeployManager.container.DeployDialog.datatable.subscribe("postRenderEvent", function() {
	                	var recordSet = YAHOO.DeployManager.container.DeployDialog.datatable.getRecordSet();
	                	var env = webapp.getEnvironment();
	                	var vh = webapp.getVirtualHost();
						for (var i = 0; i < recordSet.getLength(); i++) {
							var record = recordSet.getRecord(i);
							if (record.getData("environment") == env && record.getData("name") == vh) {
								YAHOO.DeployManager.container.DeployDialog.datatable.selectRow(record);
								break;
							} 
						}
	                	
	                });						
                    
                } else {
                    
                	YAHOO.DeployManager.container.DeployDialog.datatable.subscribe("rowMouseoverEvent", YAHOO.DeployManager.container.DeployDialog.datatable.onEventHighlightRow); 
                	YAHOO.DeployManager.container.DeployDialog.datatable.subscribe("rowMouseoutEvent", YAHOO.DeployManager.container.DeployDialog.datatable.onEventUnhighlightRow);  
                	YAHOO.DeployManager.container.DeployDialog.datatable.subscribe("rowClickEvent", YAHOO.DeployManager.container.DeployDialog.onEventSelectRow);
                	document.getElementById("DeployDialogContext").style.background = ""; 
                }

            	YAHOO.DeployManager.container.DeployDialog.refresh();
                YAHOO.DeployManager.container.DeployDialog.dialog.show();
                YAHOO.DeployManager.container.DeployDialog.dialog.center();
                YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.DeployDialog.dialog);
                
            }

            YAHOO.DeployManager.container.DeployDialog.onEventSelectRow = function(o) {	
            	YAHOO.DeployManager.container.DeployDialog.dialog.getButtons()[2].set("disabled", false);
            	YAHOO.DeployManager.container.DeployDialog.datatable.onEventSelectRow(o);
            	var recordSel = YAHOO.DeployManager.container.DeployDialog.datatable.getSelectedRows()[0];
      	       	var record = YAHOO.DeployManager.container.DeployDialog.datatable.getRecord(recordSel);
            	document.getElementById("DeployDialogEnvironment").value = record.getData("environment");
            	document.getElementById("DeployDialogVirtualHost").value = record.getData("name");
            }
            
            YAHOO.DeployManager.container.DeployDialog.cancel = function() {
            	YAHOO.DeployManager.container.DeployDialog.dialog.hide();
            }
            
            YAHOO.DeployManager.container.DeployDialog.back = function() {
            	YAHOO.DeployManager.container.DeployDialog.setCurrentTab(YAHOO.DeployManager.container.DeployDialog.currentTab - 1);
            }

            YAHOO.DeployManager.container.DeployDialog.next = function() {
            	YAHOO.DeployManager.container.DeployDialog.setCurrentTab(YAHOO.DeployManager.container.DeployDialog.currentTab + 1);
            }
            
            YAHOO.DeployManager.container.DeployDialog.deploy = function() {
            	YAHOO.DeployManager.container.DeployDialog.next();
            	var form = document.getElementById("sendDeploy");
            	AIM.submit(form);	
            	document.getElementById("sendDeploy").submit();
            	var querystring = "DeployDialogEnvironment=" + document.getElementById("DeployDialogEnvironment").value + "&";
            	querystring += "DeployDialogVirtualHost=" + document.getElementById("DeployDialogVirtualHost").value + "&";
            	querystring += "DeployDialogContext=" + document.getElementById("DeployDialogContext").value;
            	YAHOO.DeployManager.container.DeployLogDialog.createAndShow(querystring);
            	YAHOO.DeployManager.container.DeployDialog.dialog.hide();    
            	window.setTimeout('YAHOO.DeployManager.container.WebAppsDialog.refresh();', 5000);        	
            }

            YAHOO.DeployManager.container.DeployDialog.checkContextName = function() {
                
		        var input = document.getElementById("DeployDialogContext");
		        
		        var env  = document.getElementById("DeployDialogEnvironment").value;
		        var vh   = document.getElementById("DeployDialogVirtualHost").value;
		        var name = input.value;
		        
            	var recordset = YAHOO.DeployManager.container.WebAppsDialog.datatable.getRecordSet();
            	var i;
            	for (i = 0; i < recordset.getLength(); i++) {
                	var record = recordset.getRecord(i);
                	if (record.getData("environment") == env && record.getData("virtualhost") == vh && record.getData("name") == name) {
                		input.style.background = "white no-repeat 400px -3px scroll url(images/alert_small_icon.png)";
                		break;
                	}
            	}

            	if (i == recordset.getLength()) {
            		input.style.background = "";
            	}
            	
            }
            
            /******************************* CONTENUTO STATICO **********************************************/
            YAHOO.DeployManager.container.StaticContentDialog.createAndShow = function() {
                
            	if (YAHOO.DeployManager.container.StaticContentDialog.dialog == null) {
	               	var html = '<div id="staticContentDialog">' + 
		                '<div class="hd">HTDocs - Contenuto Statio</div> ' +
		                '<div class="bd" style="overflow: auto;"> ' +
		                    '<div id="staticContentDataTable"></div> ' +
		                 '</div>' + 
		              '</div>'; 
		
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 

	                var menuCompare = [
										{ text: "File"     , onclick: { fn: YAHOO.DeployManager.container.StaticContentDialog.comparefile } }, 
					                    { text: "Contenuto", onclick: { fn: YAHOO.DeployManager.container.StaticContentDialog.comparecontent } } 
	                    			  ]; 

	                var menuTask = [
		           						{ text: "Tag"      , onclick: { fn: YAHOO.DeployManager.container.StaticContentDialog.tag } }, 
		           	                    { text: "Tag e metti in produzione", onclick: { fn: YAHOO.DeployManager.container.StaticContentDialog.tageprod } },
		           						{ text: "Metti in produzione specifico tag", onclick: { fn: YAHOO.DeployManager.container.StaticContentDialog.taginprod } }
	           	                   ]; 
	                    
	                var dialog = new YAHOO.widget.Dialog("staticContentDialog",  
	                        { width: "700px", height: "400px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Confronta", type: "menu", menu: menuCompare },
	        	                          { text: "Esegui", type: "menu", menu: menuTask },
	                                      { text: "Notifiche", handler: YAHOO.DeployManager.container.StaticContentDialog.notify },
	        	                          { text: "Ok", handler: YAHOO.DeployManager.container.StaticContentDialog.ok, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                dialog.render();
	                YAHOO.DeployManager.container.manager.register(dialog);

	                var resize = new YAHOO.util.Resize("staticContentDialog", {
		                                  handles: ["br"], autoRatio: false, minWidth: 300, minHeight: 100, status: false } );

	                resize.on("startResize", function(args) {
	        		    if (this.cfg.getProperty("constraintoviewport")) {
	                        var D = YAHOO.util.Dom;
	                        var clientRegion = D.getClientRegion();
	                        var elRegion = D.getRegion(this.element);
	                        resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
	                        resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
	    	            } else {
	                        resize.set("maxWidth", null);
	                        resize.set("maxHeight", null);
	    	        	}

	               	}, dialog, true);
	
		            resize.on("resize", function(args) {
							var panelHeight = args.height;
							var panelWidth = args.width;
		                	this.cfg.setProperty("height", panelHeight + "px"); 
			                YAHOO.DeployManager.container.StaticContentDialog.datatable.set("width", panelWidth - 25 + "px");
			                YAHOO.DeployManager.container.StaticContentDialog.datatable.set("height", panelHeight - 120 + "px");
		                }, dialog, true);                
		                
					var myColumnDefs = [ 
	            		{ key:"name", label: "Nome", sortable:true, resizeable:true, width: 100 },
	            		{ key:"url", label: "URL", sortable:true, resizeable:true, width: 180 },   
	            		{ key:"productRelease", label: "Versione in produzione", sortable:true, resizeable:true, width: 330 } ]; 
	
		            var myDataSource = new YAHOO.util.DataSource(server + "manager/svnproject");
		            myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
		            myDataSource.responseSchema = { resultNode: "svnproject", fields: ["name", "url", "productRelease" ] };
		            YAHOO.DeployManager.container.StaticContentDialog.datasource = myDataSource;
		                
				    var myDataTable = new YAHOO.widget.ScrollingDataTable("staticContentDataTable", myColumnDefs, myDataSource, 
						    {selectionMode: "single", height: "273px" }); 
	
				    myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow); 
				    myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);  
				    myDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.StaticContentDialog.onEventSelectRow); 
				    myDataTable.subscribe("rowDblclickEvent", YAHOO.DeployManager.container.StaticContentDialog.onDblclickRow);
				    YAHOO.DeployManager.container.StaticContentDialog.datatable = myDataTable;
	
				    YAHOO.DeployManager.container.StaticContentDialog.refresh = function () {
				    	myDataTable.getDataSource().sendRequest(
			    			myDataTable._request,
			    			myDataTable.onDataReturnInitializeTable,
			    			myDataTable
			        	); 
				    }
				    YAHOO.DeployManager.container.StaticContentDialog.dialog = dialog;
				} else {
            		YAHOO.DeployManager.container.StaticContentDialog.refresh();
				}
            	YAHOO.DeployManager.container.StaticContentDialog.dialog.getButtons()[0].set("disabled", true);
            	YAHOO.DeployManager.container.StaticContentDialog.dialog.getButtons()[1].set("disabled", true);
            	YAHOO.DeployManager.container.StaticContentDialog.dialog.getButtons()[2].set("disabled", true);
                YAHOO.DeployManager.container.StaticContentDialog.dialog.show();
                YAHOO.DeployManager.container.StaticContentDialog.dialog.center();
                YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.StaticContentDialog.dialog);
            }
            
            YAHOO.DeployManager.container.StaticContentDialog.onDblclickRow = function(o) {
            	//var record = YAHOO.DeployManager.container.StaticContentDialog.datatable.getRecord(o.target);
            	//YAHOO.DeployManager.container.StaticContentDialog.currentrecord = record; 
            }
            
	        YAHOO.DeployManager.container.StaticContentDialog.onEventSelectRow = function(o) {
	        	YAHOO.DeployManager.container.StaticContentDialog.datatable.onEventSelectRow(o);
               	YAHOO.DeployManager.container.StaticContentDialog.dialog.getButtons()[0].set("disabled", false);
            	YAHOO.DeployManager.container.StaticContentDialog.dialog.getButtons()[1].set("disabled", false);
            	YAHOO.DeployManager.container.StaticContentDialog.dialog.getButtons()[2].set("disabled", false);
            	var record = YAHOO.DeployManager.container.StaticContentDialog.datatable.getRecord(o.target);
            	YAHOO.DeployManager.container.StaticContentDialog.currentrecord = record; 
	        }
	            
	        YAHOO.DeployManager.container.StaticContentDialog.ok = function() {
	        	YAHOO.DeployManager.container.StaticContentDialog.dialog.hide();
            }

	        YAHOO.DeployManager.container.StaticContentDialog.tag = function() {
	        	var projectname = YAHOO.DeployManager.container.StaticContentDialog.currentrecord.getData("name");
	        	YAHOO.DeployManager.container.TagDialog.createAndShow(projectname, "tag");
	        }

			YAHOO.DeployManager.container.StaticContentDialog.tageprod = function() {
		     	var projectname = YAHOO.DeployManager.container.StaticContentDialog.currentrecord.getData("name");
	        	YAHOO.DeployManager.container.TagDialog.createAndShow(projectname, "tageprod"); 
	        }

			YAHOO.DeployManager.container.StaticContentDialog.taginprod = function() {
			  	var projectname = YAHOO.DeployManager.container.StaticContentDialog.currentrecord.getData("name");
	        	YAHOO.DeployManager.container.TagDialog.createAndShow(projectname, "taginprod"); ;
			}

			YAHOO.DeployManager.container.StaticContentDialog.comparefile = function() {
				var projectname = YAHOO.DeployManager.container.StaticContentDialog.currentrecord.getData("name");
				YAHOO.DeployManager.container.CompareLogDialog.createAndShow(projectname, "filename");
	        }

			YAHOO.DeployManager.container.StaticContentDialog.comparecontent = function() {
				var projectname = YAHOO.DeployManager.container.StaticContentDialog.currentrecord.getData("name");
				YAHOO.DeployManager.container.CompareLogDialog.createAndShow(projectname, "content");
	        }

			YAHOO.DeployManager.container.StaticContentDialog.notify = function() {
				var projectname = YAHOO.DeployManager.container.StaticContentDialog.currentrecord.getData("name");
				svnproject = new BussinessObject.SvnProject(projectname);
				YAHOO.DeployManager.container.StaticNotifyDialog.createAndShow(svnproject);
			}
			
			/******************************* NOTIFY CONFIGURATION ***************************************************/
			YAHOO.DeployManager.container.StaticNotifyDialog.createAndShow = function(svnproject) {
                
            	if (YAHOO.DeployManager.container.StaticNotifyDialog.dialog == null) {
	               	var html = '<div id="StaticNotifyDialog">' + 
		                '<div class="hd">Email notify on changes</div> ' +
		                '<div class="bd"> ' +
		                    '<label style="display: inline; width: 100%; float: left; margin-bottom: 10px;">Emails:  ' +
	                    		'<input style="display: inline; width: 85%; float: right;" type="text" id="StaticNotifyDialogEmails" name="StaticNotifyDialogEmails"></input></label>' +
	                    	'<input id="StaticNotifyDialogAdd" name="StaticNotifyDialogAdd" type="checkbox">Aggiunti</input>' +
	                    	'<input id="StaticNotifyDialogMod" name="StaticNotifyDialogMod" type="checkbox" style="margin-left: 30px;">Modificati</input>' +
	                    	'<input id="StaticNotifyDialogDel" name="StaticNotifyDialogDel" type="checkbox" style="margin-left: 30px;">Rimossi</input>' +
		                 '</div>' + 
		              '</div>';  
		
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
	                    
	                var dialog = new YAHOO.widget.Dialog("StaticNotifyDialog",  
	                        { width: "480px", height: "135px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Salva",  handler: YAHOO.DeployManager.container.StaticNotifyDialog.save },
	                                      { text: "Chiudi", handler: YAHOO.DeployManager.container.StaticNotifyDialog.close, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                dialog.render();
	                YAHOO.DeployManager.container.manager.register(dialog);
 
				    YAHOO.DeployManager.container.StaticNotifyDialog.dialog = dialog;
				}

            	YAHOO.DeployManager.container.StaticNotifyDialog.svnproject = svnproject;
            	document.getElementById("StaticNotifyDialogEmails").value = "";
            	document.getElementById("StaticNotifyDialogAdd").checked = false;
            	document.getElementById("StaticNotifyDialogMod").checked = false;
            	document.getElementById("StaticNotifyDialogDel").checked = false;
            	
            	document.getElementById("StaticNotifyDialogEmails").value = svnproject.getEmails();

            	if (svnproject.getNotifyAdded() == "true") 
            		document.getElementById("StaticNotifyDialogAdd").checked = true;

            	if (svnproject.getNotifyModified() == "true") 
            		document.getElementById("StaticNotifyDialogMod").checked = true;

            	if (svnproject.getNotifyRemoved() == "true") 
            		document.getElementById("StaticNotifyDialogDel").checked = true;
            	
            	
                YAHOO.DeployManager.container.StaticNotifyDialog.dialog.show();
                YAHOO.DeployManager.container.StaticNotifyDialog.dialog.center();
                YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.StaticNotifyDialog.dialog);
            }
            
	        YAHOO.DeployManager.container.StaticNotifyDialog.close = function() {
	        	YAHOO.DeployManager.container.StaticNotifyDialog.dialog.hide();
            }

	        YAHOO.DeployManager.container.StaticNotifyDialog.save = function() {
		        var svnproject = YAHOO.DeployManager.container.StaticNotifyDialog.svnproject;
		        svnproject.setEmails(document.getElementById("StaticNotifyDialogEmails").value);
		        svnproject.setNotifyAdded("false");
				svnproject.setNotifyModified("false")
		        svnproject.setNotifyRemoved("false");
		        
		        if (document.getElementById("StaticNotifyDialogAdd").checked)
		        	svnproject.setNotifyAdded("true");

		        if (document.getElementById("StaticNotifyDialogMod").checked)
		        	svnproject.setNotifyModified("true");

		        if (document.getElementById("StaticNotifyDialogDel").checked)
		        	svnproject.setNotifyRemoved("true");
		         
		        BussinessMethos.saveSvnProject(svnproject);
		        
		        YAHOO.DeployManager.container.StaticNotifyDialog.dialog.hide();
            }
            
			
			/******************************* TAG AND EXPORT PROD  ***************************************************/
			YAHOO.DeployManager.container.TagDialog.createAndShow = function(project, mode) {
                
            	if (YAHOO.DeployManager.container.TagDialog.dialog == null) {
	               	var html = '<div id="tagDialog">' + 
		                '<div class="hd">Tag</div> ' +
		                '<div class="bd"> ' +
		                    '<div id="tagDataTable" style="margin: auto auto 5px; width: 454px;"></div> ' +
		                    '<label style="display: inline; width: 90%; float: left;">Nome Tag:  ' +
	                    	'<input style="display: inline; width: 65%; float: right;" type="text" id="TagDialogTagName" name="TagDialogTagName"></input></label>' +
	                    	'<label style="display: inline; width: 90%; float: left;">Messaggio:  ' +
	                    	'<input style="display: inline; width: 65%; float: right;" type="text" id="TagDialogMessage" name="TagDialogMessage"></input></label>' +
		                 '</div>' + 
		              '</div>';  
		
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
	                    
	                var dialog = new YAHOO.widget.Dialog("tagDialog",  
	                        { width: "480px", height: "370px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "",       handler: YAHOO.DeployManager.container.TagDialog.go },
	                                      { text: "Chiudi", handler: YAHOO.DeployManager.container.TagDialog.close, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                dialog.render();
	                YAHOO.DeployManager.container.manager.register(dialog);

					var myColumnDefs = [ 
	            		{ key:"name", label: "Tag", sortable:true, resizeable:true, width: 155 },
	            		{ key:"message", label: "Messaggio", sortable:true, resizeable:true, width: 255 } ]; 
	
		            var myDataSource = new YAHOO.util.DataSource(server + "services/ExecuteTag?project=" + project);
		            myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
		            myDataSource.responseSchema = { resultNode: "tag", fields: ["name", "message" ] };
		            YAHOO.DeployManager.container.TagDialog.datasource = myDataSource;
		                
				    var myDataTable = new YAHOO.widget.ScrollingDataTable("tagDataTable", myColumnDefs, myDataSource, 
						    {selectionMode: "single", height: "200px" }); 
	
				    myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow); 
				    myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);  
				    myDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.TagDialog.onEventSelectRow); 
				    YAHOO.DeployManager.container.TagDialog.datatable = myDataTable;
	
				    YAHOO.DeployManager.container.TagDialog.refresh = function () {
				    	myDataTable.getDataSource().sendRequest(
			    			myDataTable._request,
			    			myDataTable.onDataReturnInitializeTable,
			    			myDataTable
			        	); 
				    }
				    YAHOO.DeployManager.container.TagDialog.dialog = dialog;

				    var oElement = document.getElementById("TagDialogTagName");
				    YAHOO.util.Event.addListener(oElement, "keyup", YAHOO.DeployManager.container.TagDialog.onTagNameKeyUp);
				    
				} else {
					YAHOO.DeployManager.container.TagDialog.datasource.liveData = server + "services/ExecuteTag?project=" + project;
	            	YAHOO.DeployManager.container.TagDialog.refresh();
				}

            	document.getElementById("TagDialogTagName").readOnly = true;
            	document.getElementById("TagDialogMessage").readOnly = true;
	        	document.getElementById("TagDialogTagName").value = "";
	        	document.getElementById("TagDialogMessage").value = "";
            	
				if (mode == "tag" || mode == "tageprod") {
					YAHOO.DeployManager.container.TagDialog.dialog.getButtons()[0].set("disabled", false);
	            	document.getElementById("TagDialogTagName").readOnly = false;
	            	document.getElementById("TagDialogMessage").readOnly = false;
					if (mode == "tageprod") 
						YAHOO.DeployManager.container.TagDialog.dialog.getButtons()[0].set("label", "Effettua Tag ed Export in produzione");
					else
						YAHOO.DeployManager.container.TagDialog.dialog.getButtons()[0].set("label", "Effettua Tag");
				} else if (mode == "taginprod") {
					YAHOO.DeployManager.container.TagDialog.dialog.getButtons()[0].set("label", "Export in produzione del Tag selezionato");
					YAHOO.DeployManager.container.TagDialog.dialog.getButtons()[0].set("disabled", true);
				}
	        	
            	YAHOO.DeployManager.container.TagDialog.project = project; 
            	YAHOO.DeployManager.container.TagDialog.mode = mode;
                YAHOO.DeployManager.container.TagDialog.dialog.show();
                YAHOO.DeployManager.container.TagDialog.dialog.center();
                YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.TagDialog.dialog);
            }
            
	        YAHOO.DeployManager.container.TagDialog.onEventSelectRow = function(o) {
               	YAHOO.DeployManager.container.TagDialog.dialog.getButtons()[0].set("disabled", false);
	        	YAHOO.DeployManager.container.TagDialog.datatable.onEventSelectRow(o);               	
            	var record = YAHOO.DeployManager.container.TagDialog.datatable.getRecord(o.target);
            	YAHOO.DeployManager.container.TagDialog.currentrecord = record; 
	        }
	            
	        YAHOO.DeployManager.container.TagDialog.close = function() {
	        	YAHOO.DeployManager.container.TagDialog.dialog.hide();
            }

	        YAHOO.DeployManager.container.TagDialog.onTagNameKeyUp = function() {
	        	var oElement = document.getElementById("TagDialogTagName");
	        	if(oElement.value.match(/\s/g)) 
	        		oElement.value = oElement.value.replace(/\s/g, "");
            }
            
	        YAHOO.DeployManager.container.TagDialog.go = function() {
		        var projectname = YAHOO.DeployManager.container.TagDialog.project;
		        var mode = YAHOO.DeployManager.container.TagDialog.mode;
	        	var tag = document.getElementById("TagDialogTagName").value;
	        	var message = document.getElementById("TagDialogMessage").value;

	        	if (tag == "")
	        		tag = YAHOO.DeployManager.container.TagDialog.currentrecord.getData("name");
	        	
	        	YAHOO.DeployManager.container.TagLogDialog.createAndShow(projectname, mode, tag, message);
	        	YAHOO.DeployManager.container.TagDialog.dialog.hide();
            }
            
	        /******************************* TAG LOG RESULT ***************************************************/
		 	YAHOO.DeployManager.container.TagLogDialog.createAndShow = function(projectname, mode, tag, message) {
			 	
            	if (YAHOO.DeployManager.container.TagLogDialog.lastid == undefined)
            		YAHOO.DeployManager.container.TagLogDialog.lastid = 1;
            	else
            		YAHOO.DeployManager.container.TagLogDialog.lastid++;
        		
        		var id = YAHOO.DeployManager.container.TagLogDialog.lastid;

        		var html = '<div id="TagLogDialog'+id+'">' + 
	                '<div class="hd">Tag/Export Result</div> ' +
	                '<div class="bd" style="overflow: auto;"> ' +
	                	'<textarea style="width: 99%; height: 400px;" id="TagLogDialogText'+id+'"></textarea>' +
	                 '</div>' + 
	              '</div>'; 
	
	            var elDiv = document.createElement("div");
	            elDiv.innerHTML = html;
	            document.body.appendChild(elDiv); 
	                
	            dialog = new YAHOO.widget.Dialog("TagLogDialog" + id,  
	                    { width: "650px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body", 
                    	  effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	            dialog.render();
	            YAHOO.DeployManager.container.manager.register(dialog);  
	            dialog.center();
	            dialog.show();
	            YAHOO.DeployManager.container.manager.focus(dialog);

	            dialog.projectname = projectname;
	            dialog.mode = mode;
	            dialog.tag = tag;
	            dialog.message = message;
	            
	            YAHOO.DeployManager.container.TagLogDialog.dialog[id] = dialog;
            	
	            var xhr = YAHOO.util.Connect.createXhrObject();
	    		var conn = xhr.conn;
	    		dialog.conn = conn;

	    		var url = server + 'services/';
				if (mode == "tag") {
					url += 'ExecuteTag?project=' + projectname + '&tag=true&export=false&tagname=' + tag + '&message=' + message;
				} else if (mode == "tageprod") {
					url += 'ExecuteTag?project=' + projectname + '&tag=true&export=true&tagname=' + tag + '&message=' + message;
				} else if (mode == "taginprod") {
					url += 'ExecuteTag?project=' + projectname + '&tag=false&export=true&tagname=' + tag;
				}
	    		
	    		conn.open("POST", url, true);
	    		YAHOO.util.Connect.setHeader(xhr);
	    		conn.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
	    		conn.send(null);

	    		var timeoutid = setInterval('YAHOO.DeployManager.container.TagLogDialog.refreshProgressive('+id+')', 100);
	    		dialog.timeoutid = timeoutid;
	    		
        	}
            
        	YAHOO.DeployManager.container.TagLogDialog.refreshProgressive = function(id) {
        		var dialog = YAHOO.DeployManager.container.TagLogDialog.dialog[id];
        		
	    		var conn = dialog.conn;
				var timeoutid = dialog.timeoutid;
				var area = document.getElementById("TagLogDialogText" + id);
				 
    			area.value = conn.responseText;
				area.scrollTop = area.scrollHeight;
				
    			if (conn.readyState == 4) {
    				clearTimeout(timeoutid); 
    				if (YAHOO.DeployManager.container.TagDialog.mode.indexOf("prod") > 0)
    					YAHOO.DeployManager.container.StaticContentDialog.refresh();
    			}
    		}
    		
			/******************************* COMPARE LOG RESULT ***************************************************/
		 	YAHOO.DeployManager.container.CompareLogDialog.createAndShow = function(projectname, type) {
            	if (YAHOO.DeployManager.container.CompareLogDialog.lastid == undefined)
            		YAHOO.DeployManager.container.CompareLogDialog.lastid = 1;
            	else
            		YAHOO.DeployManager.container.CompareLogDialog.lastid++;
        		
        		var id = YAHOO.DeployManager.container.CompareLogDialog.lastid;

        		var html = '<div id="CompareLogDialog'+id+'">' + 
	                '<div class="hd">Compare Result</div> ' +
	                '<div class="bd" style="overflow: auto;"> ' +
	                	'<textarea style="width: 99%; height: 400px;" id="CompareLogDialogText'+id+'"></textarea>' +
	                 '</div>' + 
	              '</div>'; 
	
	            var elDiv = document.createElement("div");
	            elDiv.innerHTML = html;
	            document.body.appendChild(elDiv); 
	                
	            dialog = new YAHOO.widget.Dialog("CompareLogDialog" + id,  
	                    { width: "650px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	            	 	  buttons : [ { text: "Aggiorna", handler: { fn: YAHOO.DeployManager.container.CompareLogDialog.refreshAll, obj: id }  },
	        	            	 	  { text: "Ripristina produzione", handler: { fn: YAHOO.DeployManager.container.CompareLogDialog.revertprod, obj: id } },
		   	                          { text: "Ok", handler: YAHOO.DeployManager.container.CompareLogDialog.ok, isDefault: true } ], 
                    	  effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	            dialog.render();
	            YAHOO.DeployManager.container.manager.register(dialog);  
	            dialog.center();
	            dialog.show();
	            YAHOO.DeployManager.container.manager.focus(dialog);

	            dialog.projectname = projectname;
	            dialog.type = type;

	            var resize = new YAHOO.util.Resize("CompareLogDialog" + id, {
                    handles: ["br"], autoRatio: false, minWidth: 300, minHeight: 100, status: false } );

				resize.on("startResize", function(args) {
				  if (this.cfg.getProperty("constraintoviewport")) {
				      var D = YAHOO.util.Dom;
				      var clientRegion = D.getClientRegion();
				      var elRegion = D.getRegion(this.element);
				      resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
				      resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
				  } else {
				      resize.set("maxWidth", null);
				      resize.set("maxHeight", null);
					}
				}, dialog, true);
				
				resize.on("resize", function(args) {
				  	var D = YAHOO.util.Dom;
					var panelHeight = args.height;
				    this.cfg.setProperty("height", panelHeight + "px");
				}, dialog, true);             
	            
	            YAHOO.DeployManager.container.CompareLogDialog.dialog[id] = dialog;
	            YAHOO.DeployManager.container.CompareLogDialog.refreshAll(dialog, id);
	            
            } 

        	YAHOO.DeployManager.container.CompareLogDialog.refreshAll = function(dialog, iddialog) { 

        		var dialog = YAHOO.DeployManager.container.CompareLogDialog.dialog[iddialog];
            	
	            var xhr = YAHOO.util.Connect.createXhrObject();
	    		var conn = xhr.conn;
	    		dialog.conn = conn;
	    		
	    		conn.open("GET", server + 'services/Compare?project=' + dialog.projectname + "&type=" + dialog.type, true);
	    		YAHOO.util.Connect.setHeader(xhr);
	    		conn.send(null);

	    		var timeoutid = setInterval('YAHOO.DeployManager.container.CompareLogDialog.refreshProgressive('+iddialog+')', 100);
	    		dialog.timeoutid = timeoutid;
	    		
        	}
            
        	YAHOO.DeployManager.container.CompareLogDialog.refreshProgressive = function(iddialog) {
        		var dialog = YAHOO.DeployManager.container.CompareLogDialog.dialog[iddialog];
        		
	    		var conn = dialog.conn;
				var timeoutid = dialog.timeoutid;
				var area = document.getElementById("CompareLogDialogText" + iddialog);
				 
    			area.value = conn.responseText;
				area.scrollTop = area.scrollHeight;
				
    			if (conn.readyState == 4) {
    				clearTimeout(timeoutid); 
    			}
    		}

           	YAHOO.DeployManager.container.CompareLogDialog.ok = function(dialog) {
            	this.hide();
        	}
        	
        	YAHOO.DeployManager.container.CompareLogDialog.revertprod = function(dialog, iddialog) {
        		var dialog = YAHOO.DeployManager.container.CompareLogDialog.dialog[iddialog];
            	
	            var xhr = YAHOO.util.Connect.createXhrObject();
	    		var conn = xhr.conn;
	    		dialog.conn = conn;
	    		
	    		conn.open("POST", server + 'services/ExecuteRevert?project=' + dialog.projectname, true);
	    		YAHOO.util.Connect.setHeader(xhr);
	    		conn.send(null);

	    		var timeoutid = setInterval('YAHOO.DeployManager.container.CompareLogDialog.refreshProgressive('+iddialog+')', 100);
	    		dialog.timeoutid = timeoutid;
        	}
	    		
            /******************************* VIRTUAL HOST DIALOG FORM ***************************************************/
            YAHOO.DeployManager.container.VirtualHostDialogForm.createAndShow = function(virtualhost) {
            	YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost = virtualhost;
            	
            	if (YAHOO.DeployManager.container.VirtualHostDialogForm.dialog == null) {
	               	var html = '<div id="virtualHostDialogForm">' + 
		                '<div class="hd">Virtual Host</div> ' +
		                '<div class="bd"> ' +
		                    '<div>' + 
								'<label for="virtualHostDialogForm_Env" id="virtualHostDialogForm_Env_Label" style="display: block; width: 45%; float: left; text-align: left;">Ambiente:  </label>' +
								'<select id="virtualHostDialogForm_Env" name="virtualHostDialogForm_Env" style="display: block; "></select>' +
								'<label for="virtualHostDialogForm_Name" id="virtualHostDialogForm_Name_Label" style="display: block; width: 45%; float: left; text-align: left;">Nome dominio:  </label>' +
								'<input type="text" id="virtualHostDialogForm_Name" name="virtualHostDialogForm_Name" style="float: left; width: 50%;" ><br/>' +
								'<label for="virtualHostDialogForm_DeploymentMethod_Datatable" id="virtualHostDialogForm_DeploymentMethod_Datatable_Label" style="display: block; width: 85%; text-align: left; clear: both; ">Modalità di deploy:  </label>' +
			                    '<div id="virtualHostDialogForm_DeploymentMethod_Datatable"></div>' +
			                    '<div style="height: 30px; margin-top: 3px;">' +
								'<span id="virtualHostDialogForm_DeploymentMethod_BtnDel" class="yui-button" style="float: right;"><span class="first-child"><button type="button">Rimuovi</button></span></span>' +
			                    '<span id="virtualHostDialogForm_DeploymentMethod_BtnAdd" class="yui-button" style="float: right;"><span class="first-child"><button type="button">Aggiungi</button></span></span>' +
			                    '</div>' +
								'<label for="virtualHostDialogForm_JMXServer_Datatable" id="virtualHostDialogForm_JMXServer_Datatable_Label" style="display: block; width: 85%; text-align: left; clear: both;">Stringa di connessione JMX di ogni server:  </label>' +			                    
			                    '<div id="virtualHostDialogForm_JMXServer_Datatable"></div>' +
			                    '<div style="height: 30px; margin-top: 3px;">' +
								'<span id="virtualHostDialogForm_JMXServer_BtnDel" class="yui-button" style="float: right;"><span class="first-child"><button type="button">Rimuovi</button></span></span>' +
			                    '<span id="virtualHostDialogForm_JMXServer_BtnAdd" class="yui-button" style="float: right;"><span class="first-child"><button type="button">Aggiungi</button></span></span> ' +
		                    '</div> ' + 
						'</div>' +
	                 '</div>';

			        var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 

	                YAHOO.DeployManager.container.VirtualHostDialogForm.dialog = new YAHOO.widget.Dialog("virtualHostDialogForm",  
	                        { width: "550px", fixedcenter: false, close: true, draggable: true, modal: true, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Annulla", handler: YAHOO.DeployManager.container.VirtualHostDialogForm.cancel, isDefault: false },
	       	                              { text: "Ok", handler: YAHOO.DeployManager.container.VirtualHostDialogForm.ok, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                YAHOO.DeployManager.container.VirtualHostDialogForm.dialog.render();
	                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.VirtualHostDialogForm.dialog);
	                
			        YAHOO.DeployManager.container.VirtualHostDialogForm.refresh = function () {
			           	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable.getDataSource().sendRequest(
		           			YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable._request,
		           			YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable.onDataReturnInitializeTable,
		            		YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable
		            	); 

			           	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable.getDataSource().sendRequest(
		           			YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable._request,
		           			YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable.onDataReturnInitializeTable,
		            		YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable
		            	); 
			           	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnDel.set("disabled", true);
			           	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnDel.set("disabled", true);
			        }

	                
	                /********************Prima tabella ***************/
	                var deploymentMethodsColumnDefs = [ { key:"string", label: "Metodi di deploy", sortable:true, resizeable:true } ]; 
   	                var deploymentMethodsDataSource = new YAHOO.util.FunctionDataSource(function() {
   	                	return xmlToJSON(YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost.getDeploymentMethods());
   	                } );
   	                
   	                YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataSource = deploymentMethodsDataSource;
   	          		deploymentMethodsDataSource.responseSchema = { fields: ["string"] };
   	                
   			        var deploymentMethodsDataTable = new YAHOO.widget.DataTable("virtualHostDialogForm_DeploymentMethod_Datatable",
   			        		deploymentMethodsColumnDefs, deploymentMethodsDataSource, {selectionMode: "single"}); 
			        YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable = deploymentMethodsDataTable;
   			     	deploymentMethodsDataTable.getTableEl().width = "100%";       
   			     	deploymentMethodsDataTable.set("MSG_EMPTY", "");

   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnAdd = new YAHOO.widget.Button("virtualHostDialogForm_DeploymentMethod_BtnAdd");
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnDel = new YAHOO.widget.Button("virtualHostDialogForm_DeploymentMethod_BtnDel");
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnDel.set("disabled", true);
   			     
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnAdd.subscribe("click", function() {
	   			     	onPromptMessage("Nuovo metodo di deploy", { 
	   	                	ok: {
	   	                		fn: function(o) {
   	                				var value = document.getElementById("promptDialogForm_Name").value;
				   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost.addDeploymentMethod(value);
			   	       	      		YAHOO.DeployManager.container.VirtualHostDialogForm.refresh();
	   	            			}
	   	                	}
	   	            	} );
   			     	} ); 

   			   		YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnDel.subscribe("click", function() {
   			   			var recordSel = YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable.getSelectedRows()[0];
   	       	       		var record = YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable.getRecord(recordSel);
   	       	      		YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost.removeDeploymentMethod(record.getData("string"));
   	       	      		YAHOO.DeployManager.container.VirtualHostDialogForm.refresh();
			     	}); 
			     	
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable_onEventSelectRow = function(o) {	
   			     		YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsBtnDel.set("disabled", false);
   		            	YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable.onEventSelectRow(o);
   		            }
   		            
   			     	deploymentMethodsDataTable.subscribe("rowMouseoverEvent", deploymentMethodsDataTable.onEventHighlightRow); 
	   			    deploymentMethodsDataTable.subscribe("rowMouseoutEvent", deploymentMethodsDataTable.onEventUnhighlightRow);  
	   			  	deploymentMethodsDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.VirtualHostDialogForm.deploymentMethodsDataTable_onEventSelectRow); 

			        /********************Seconda tabella ***************/
	                var jmxServersToMonitorColumnDefs = [ { key:"string", label: "Indirizzo", sortable:true, resizeable:true } ]; 

   	                var jmxServersToMonitorDataSource = new YAHOO.util.FunctionDataSource( function() {
   	                	return xmlToJSON(YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost.getJMXServersToMonitor());
	   	            } ); 

   	          		jmxServersToMonitorDataSource.responseSchema = { fields: [ "string" ] };
   	                YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataSource = jmxServersToMonitorDataSource;
   	                
   			        var jmxServersToMonitorDataTable = new YAHOO.widget.DataTable("virtualHostDialogForm_JMXServer_Datatable",
   			        		jmxServersToMonitorColumnDefs, jmxServersToMonitorDataSource, {selectionMode: "single"}); 
			        YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable = jmxServersToMonitorDataTable;
   			     	jmxServersToMonitorDataTable.getTableEl().width = "100%";       
   			  		jmxServersToMonitorDataTable.set("MSG_EMPTY", "");

   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnAdd = new YAHOO.widget.Button("virtualHostDialogForm_JMXServer_BtnAdd");
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnDel = new YAHOO.widget.Button("virtualHostDialogForm_JMXServer_BtnDel");
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnDel.set("disabled", true);
   			     
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnAdd.subscribe("click", function() {
	   			     	onPromptMessage("Nuovo connettore JMX di monitoraggio", { 
	   	                	ok: {
	   	                		fn: function(o) {
		                			var value = document.getElementById("promptDialogForm_Name").value;
				   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost.addJMXServersToMonitor(value);
			   	       	      		YAHOO.DeployManager.container.VirtualHostDialogForm.refresh();
	   	            			}
	   	                	}
	   	            	} );
   			     	}); 

   			   		YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnDel.subscribe("click", function() {
   			   			var recordSel = YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable.getSelectedRows()[0];
	       	       		var record = YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable.getRecord(recordSel);
	       	      		YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost.removeJMXServerToMonitor(record.getData("string"));
	       	      		YAHOO.DeployManager.container.VirtualHostDialogForm.refresh();
			     	}); 
			     	
   			     	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable_onEventSelectRow = function(o) {	
   			     		YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorBtnDel.set("disabled", false);
   		            	YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable.onEventSelectRow(o);
   		            }
   		            
   			     	jmxServersToMonitorDataTable.subscribe("rowMouseoverEvent", jmxServersToMonitorDataTable.onEventHighlightRow); 
   			  		jmxServersToMonitorDataTable.subscribe("rowMouseoutEvent", jmxServersToMonitorDataTable.onEventUnhighlightRow);  
   					jmxServersToMonitorDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.VirtualHostDialogForm.jmxServersToMonitorDataTable_onEventSelectRow); 

   					var oElement = document.getElementById("virtualHostDialogForm_Name");
   					YAHOO.util.Event.addListener(oElement, "keyup", YAHOO.DeployManager.container.VirtualHostDialogForm.checkVirtualHostName);
   					oElement = document.getElementById("virtualHostDialogForm_Env");
   					YAHOO.util.Event.addListener(oElement, "change", YAHOO.DeployManager.container.VirtualHostDialogForm.checkVirtualHostName);
   					
            	} else {
            		YAHOO.DeployManager.container.VirtualHostDialogForm.refresh();
            	}

            	//aggiorno il contenuto della combo
            	var combo = document.getElementById("virtualHostDialogForm_Env");
            	while (combo.length > 0)
            		combo.remove(0);
        		
				var root = BussinessMethos.getEnvironments();
				var nodes = evalutateXPath(root, "list/environment");           	
            	for (var i = 0; i < nodes.length; i++) {
            		addOption(getContentInElement(evalutateXPath(nodes[i],"name")[0]), combo, true);
            	}
            	
				combo.value = virtualhost.getEnvironment();
            	document.getElementById("virtualHostDialogForm_Name").value = virtualhost.getName();
            	
            	var input = document.getElementById("virtualHostDialogForm_Name"); 
            	input.style.background = "";
            	
                YAHOO.DeployManager.container.VirtualHostDialogForm.dialog.show();
                YAHOO.DeployManager.container.VirtualHostDialogForm.dialog.center();
                YAHOO.DeployManager.container.manager.focus(YAHOO.DeployManager.container.VirtualHostDialogForm.dialog);
            	
            }
            
            YAHOO.DeployManager.container.VirtualHostDialogForm.ok = function() {
                //send update
                var virtualhost = YAHOO.DeployManager.container.VirtualHostDialogForm.currentVirtualhost;
                virtualhost.setEnvironment(document.getElementById("virtualHostDialogForm_Env").value);
                virtualhost.setName(document.getElementById("virtualHostDialogForm_Name").value);
                BussinessMethos.saveVirtualHost(virtualhost);
               
            	YAHOO.DeployManager.container.VirtualHostDialogForm.dialog.hide();
            	//refresh parent's dialog
            	YAHOO.DeployManager.container.VirtualHostDialog.refresh(); 
            }

            YAHOO.DeployManager.container.VirtualHostDialogForm.cancel = function() {
            	YAHOO.DeployManager.container.VirtualHostDialogForm.dialog.hide();            	
            }

            YAHOO.DeployManager.container.VirtualHostDialogForm.checkVirtualHostName = function() {
                var combo = document.getElementById("virtualHostDialogForm_Env");
		        var input = document.getElementById("virtualHostDialogForm_Name");
		        var env = combo.value;
		        var name = input.value;
		        
            	var recordset = YAHOO.DeployManager.container.VirtualHostDialog.datatable.getRecordSet();
            	var i;
            	for (i = 0; i < recordset.getLength(); i++) {
                	var record = recordset.getRecord(i);
                	if (record.getData("environment") == env && record.getData("name") == name) {
                		input.style.background = "white no-repeat 240px -3px scroll url(images/alert_small_icon.png)";
                		break;
                	}
            	}

            	if (i == recordset.getLength()) {
            		input.style.background = "";
            	}
	        	
            }
            
            /******************************* VIRTUAL HOST DIALOG ***************************************************/
            YAHOO.DeployManager.container.VirtualHostDialog.createAndShow = function() {

            	if (YAHOO.DeployManager.container.VirtualHostDialog.dialog == null) {
	               	var html = '<div id="virtualHostDialog">' + 
		                '<div class="hd">Virtual Hosts</div> ' +
		                '<div class="bd" style="overflow: auto;"> ' +
		                    '<div id="virtualHostDataTable" style="width: 100%;"></div> ' +
		                 '</div>' + 
		              '</div>'; 
	
	                var elDiv = document.createElement("div");
	                elDiv.innerHTML = html;
	                document.body.appendChild(elDiv); 
	                    
	                YAHOO.DeployManager.container.VirtualHostDialog.dialog = new YAHOO.widget.Dialog("virtualHostDialog",  
	                        { width: "500px", height: "300px", fixedcenter: false, close: true, draggable: true, modal: false, visible: false, zIndex: 2, autofillheight: "body",
	                          buttons : [ { text: "Aggiungi", handler: YAHOO.DeployManager.container.VirtualHostDialog.newRow, isDefault: false },
	                                      { text: "Modifica", handler: YAHOO.DeployManager.container.VirtualHostDialog.modRow, isDefault: false },
	                                      { text: "Elimina", handler: YAHOO.DeployManager.container.VirtualHostDialog.delRow, isDefault: false },
	       	                              { text: "Ok", handler: YAHOO.DeployManager.container.VirtualHostDialog.ok, isDefault: true } ], 
	                          effect: { effect: YAHOO.widget.ContainerEffect.FADE, duration:0.5} } );
	                YAHOO.DeployManager.container.VirtualHostDialog.dialog.render();
	                YAHOO.DeployManager.container.manager.register(YAHOO.DeployManager.container.VirtualHostDialog.dialog);
	                YAHOO.DeployManager.container.VirtualHostDialog.dialog.getButtons()[1].set("disabled", true);             
	                
	                var myColumnDefs = [ 
	            		{ key:"environment", label: "Ambiente", sortable:true, resizeable:false, width: 110  },  
	            		{ key:"name", label: "Virtual Host", sortable:true, resizeable:false, width: 170 },
	            		{ key:"numWebApps", label: "Numero WebApps", formatter: YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:false, width: 120 } ]; 

	                var myDataSource = new YAHOO.util.DataSource(server + "manager/virtualhost");
	                myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
	                myDataSource.responseSchema = { resultNode: "virtualhost", fields: ["environment", "name", "numWebApps" ] };
	                YAHOO.DeployManager.container.VirtualHostDialog.datasource = myDataSource;
	                
			        var myDataTable = new YAHOO.widget.ScrollingDataTable("virtualHostDataTable", myColumnDefs, myDataSource, 
					        {selectionMode: "single", height: "100%" }); 
			        
			        myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow); 
			        myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);  
			        myDataTable.subscribe("rowClickEvent", YAHOO.DeployManager.container.VirtualHostDialog.onEventSelectRow); 
			        YAHOO.DeployManager.container.VirtualHostDialog.datatable = myDataTable;

			        YAHOO.DeployManager.container.VirtualHostDialog.refresh = function () {
			           	YAHOO.DeployManager.container.VirtualHostDialog.datatable.getDataSource().sendRequest(
		           			YAHOO.DeployManager.container.VirtualHostDialog.datatable._request,
		           			YAHOO.DeployManager.container.VirtualHostDialog.datatable.onDataReturnInitializeTable,
		            		YAHOO.DeployManager.container.VirtualHostDialog.datatable
		            	); 
			        }
			        
            	} else {
	            	YAHOO.DeployManager.container.VirtualHostDialog.refresh();
            	}
            	 
                YAHOO.DeployManager.container.VirtualHostDialog.dialog.show();

            }

            YAHOO.DeployManager.container.VirtualHostDialog.onEventSelectRow = function(o) {	
            	YAHOO.DeployManager.container.VirtualHostDialog.dialog.getButtons()[1].set("disabled", false);
            	YAHOO.DeployManager.container.VirtualHostDialog.datatable.onEventSelectRow(o);
            }
            
            YAHOO.DeployManager.container.VirtualHostDialog.ok = function() {
            	YAHOO.DeployManager.container.VirtualHostDialog.dialog.hide();
            }
            
            YAHOO.DeployManager.container.VirtualHostDialog.delRow = function() {
            	var recordSel = YAHOO.DeployManager.container.VirtualHostDialog.datatable.getSelectedRows()[0];
       	       	var record = YAHOO.DeployManager.container.VirtualHostDialog.datatable.getRecord(recordSel);

            	onAlertMessage("Sicuro di voler eliminare il Virtual Host " + record.getData("name") + " di " + record.getData("environment") + "?", { 
                	yes: {
                		  fn: function(o) {
            					var env = new BussinessObject.VirtualHost(record.getData("environment") + "," + record.getData("name").replace(new RegExp("\\.", "gi"), ":"));
	                			env.setToDelete(true);
	                			BussinessMethos.saveVirtualHost(env); 
	                			YAHOO.DeployManager.container.VirtualHostDialog.datatable.deleteRow(recordSel);
	                		}, 
                		  obj: record
                		}                      	
            	} );
            }

            YAHOO.DeployManager.container.VirtualHostDialog.newRow = function() {
            	var virtualhost = new BussinessObject.VirtualHost();
            	YAHOO.DeployManager.container.VirtualHostDialogForm.createAndShow(virtualhost);
            }
            
            YAHOO.DeployManager.container.VirtualHostDialog.modRow = function() {
            	var recordSel = YAHOO.DeployManager.container.VirtualHostDialog.datatable.getSelectedRows()[0];
       	       	var record = YAHOO.DeployManager.container.VirtualHostDialog.datatable.getRecord(recordSel);
       	     	var env = new BussinessObject.VirtualHost(record.getData("environment") + "," + record.getData("name").replace(new RegExp("\\.", "gi"), ":"));
            	YAHOO.DeployManager.container.VirtualHostDialogForm.createAndShow(env);
            }

        </script>

    </head>
    
    <body class="yui-skin-sam">
          <div id="menubar" class="yuimenubar"> 
		    <div class="bd"> 
		        <ul class="first-of-type"> 
		            <li class="yuimenubaritem first-of-type"> 
		                <a class="yuimenubaritemlabel" href="#file">Configurazione</a> 
		                <div id="file" class="yuimenu"> 
		                    <div class="bd"> 
		                        <ul> 
		                            <li class="yuimenuitem"> 
		                                <a class="yuimenuitemlabel" href="javascript:YAHOO.DeployManager.container.EnvironmentDialog.createAndShow();">Ambiente... <em class="helptext">Ctrl + A</em></a> 
		                            </li>
		                            <li class="yuimenuitem"> 
		                                <a class="yuimenuitemlabel" href="javascript:YAHOO.DeployManager.container.VirtualHostDialog.createAndShow();">Virtual Host... <em class="helptext">Ctrl + V</em></a> 
		                            </li> 
		                        </ul> 
		                    </div> 
		                </div>       
		            </li> 
		            <li class="yuimenubaritem first-of-type">
		            	<a class="yuimenubaritemlabel" href="javascript:YAHOO.DeployManager.container.WebAppsDialog.createAndShow();">Web Apps...</a> 
		            </li>
					<li class="yuimenubaritem first-of-type">
		            	<a class="yuimenubaritemlabel" href="javascript:YAHOO.DeployManager.container.StaticContentDialog.createAndShow();">Contenuto statico...</a> 
		            </li> 
		            <li class="yuimenubaritem first-of-type">
		            	<a class="yuimenubaritemlabel" href="javascript:YAHOO.DeployManager.container.HelpDialog.createAndShow();">Help...</a> 
		            </li> 
		            <li class="yuimenubaritem first-of-type"> 
		            	<a class="yuimenubaritemlabel" href="javascript:BussinessMethos.logout();javascript:location.reload(true);">Logout</a> 
		            </li>
		             <li class="yuimenubaritem first-of-type" style="float: right;"> 
		            	<a class="yuimenubaritemlabel" href="#"></a> 
		            </li>
		        </ul> 
		    </div> 
		</div>     
		
    	<div id="waitDialog">
    		<div class="hd">Loading, please wait...</div> 
    		<div class="bd"><img src="images/loading.gif" /></div>
    	</div>
    	
    	<div id="alertDialog">
    		<div class="hd">Attenzione</div> 
    		<div class="bd"></div>
    	</div>
 
         <div id="errorMessageDialog" onkeypress="if (event.keyCode == 27) YAHOO.DeployManager.container.errorMessageDialog.dialog.hide();">
            <div class="hd">Errore</div>
            <div class="bd"></div>
        </div>
    
    	<div id="promptDialogForm"> 
	        <div class="hd">Nuovo</div> 
	        <div class="bd"> 
	            <label>Nome:</label> 
	            <input type="textbox" id="promptDialogForm_Name" name="promptDialogForm_Name" size="35" /> 
	         </div>
	    </div>
		                 
    	<div id="loginDialog" style="visibility:hidden"> 
		    <div class="hd">Login</div> 
		    <div class="bd">
		    	<form action="" name="login" onkeypress="if (event.keyCode == 13) YAHOO.DeployManager.container.loginDialog.handleLoginSubmit();" >
					<div class="smallTitle" id="loginDialogWelcome">Benvenuto nel RCS Deploy Manager.</div>
					<br id="loginDialogBr" />
					<div class="smallText">
						<table class="table_space" cellpadding="5" cellspacing="5" border="0" width="100%">
							<tr>
								<td style="width: 80px"><label for="username" id="loginDialogName">Username:</label></td>
								<td colspan="2"><input type="text" name="username" id="username" class="textBox" style="width: 97%" /></td>
							</tr>
							<tr>
								<td><label for="password">Password:</label></td>
								<td colspan="2"><input type="password" name="password" id="password" class="textBox" style="width: 97%" /></td>
							</tr> 
							<tr>
								<td></td>
								<td><input name="rempassword" id="rempassword" type="checkbox"></input></td>
								<td style="text-align: left;"><label for="rempassword">Ricorda credenziali</label></td>
							</tr>
							<tr id="serverTR">
								<td><label for="server">Server:</label></td>
								<td colspan="2"><input type="text" name="server" id="server" class="textBox" style="width: 97%" value="http://localhost:8080/DeployManager/"/></td>
							</tr>
						</table>
					</div>
				</form>
		    </div>
		</div> 

    </body>
    
</html>

